View source: R/geom-sideviolin.r
geom_xsideviolin | R Documentation |
The xside and yside variants of geom_violin
geom_xsideviolin( mapping = NULL, data = NULL, stat = "ydensity", position = "dodge", ..., draw_quantiles = NULL, trim = TRUE, scale = "area", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_ysideviolin( mapping = NULL, data = NULL, stat = "ydensity", position = "dodge", ..., draw_quantiles = NULL, trim = TRUE, scale = "area", na.rm = FALSE, orientation = "y", 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 |
Use to override the default connection between
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
draw_quantiles |
If |
trim |
If |
scale |
if "area" (default), all violins have the same area (before trimming the tails). If "count", areas are scaled proportionally to the number of observations. If "width", all violins have the same maximum width. |
na.rm |
If |
orientation |
The orientation of the layer. The default ( |
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
geom_*sideboxplot
df <- expand.grid(UpperCase = LETTERS, LowerCase = letters) df$Combo_Index <- as.integer(df$UpperCase)*as.integer(df$LowerCase) p1 <- ggplot(df, aes(UpperCase, LowerCase)) + geom_tile(aes(fill = Combo_Index)) #sideviolins #Note - Mixing discrete and continuous axis scales #using xsideviolins when the y aesthetic was previously #mapped with a continuous varialbe will prevent #any labels from being plotted. This is a feature that #will hopefully be added to ggside in the future. p1 + geom_xsideviolin(aes(y = Combo_Index)) + geom_ysideviolin(aes(x = Combo_Index)) #sideviolins with swapped orientation #Note - Discrete before Continuous #If you are to mix Discrete and Continuous variables on #one axis, ggplot2 prefers the discrete variable to be mapped #BEFORE the continuous. ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + geom_xsideviolin(aes(y = Species), orientation = "y") + geom_point() #Alternatively, you can recast the value as a factor and then # a numeric ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species))+ geom_point() + geom_xsideviolin(aes(y = as.numeric(Species)), orientation = "y") + geom_ysideviolin(aes(x = as.numeric(Species)), orientation = "x")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.