View source: R/geom-sidetile.r
geom_xsidetile | R Documentation |
The xside and yside variants of geom_tile
geom_xsidetile( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_ysidetile( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this
layer, either as a |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
XLayer or YLayer object to be added to a ggplot object
library(dplyr) library(tidyr) df <- mutate(diamonds, colclar = interaction(color, clarity, sep = "_", drop = TRUE)) %>% group_by(color, clarity, colclar, cut) %>% summarise(m_price = mean(price)) xside_data <- df %>% ungroup() %>% select(colclar, clarity, color) %>% mutate_all(~factor(as.character(.x), levels = levels(.x))) %>% pivot_longer(cols = c(clarity, color)) %>% distinct() p <- ggplot(df, aes(x = colclar, cut)) + geom_tile(aes(fill = m_price)) + viridis::scale_fill_viridis(option = "magma") + theme(axis.text.x = element_blank()) p + geom_xsidetile(data = xside_data, aes(y = name, xfill = value)) + guides(xfill = guide_legend(nrow = 8))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.