View source: R/position_stackx.R
position_stackx | R Documentation |
Stack overlapping objects which can be shifted vertically or horizontally
position_stackx(vjust = 1, hexpand = NA, vexpand = NA, reverse = FALSE)
vjust |
Vertical adjustment for geoms that have a position
(like points or lines), not a dimension (like bars or areas). Set to
|
hexpand |
numeric, distance to be shifted horizontally for geoms that have a position, default is NA. |
vexpand |
numeric, distance to be shifted vertically for geoms that have a position, default is NA. |
reverse |
If |
position method.
Shuangbin Xu
library(ggplot2)
library(patchwork)
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
#
p1 <- ggplot(df, aes(x=trt, y=outcome)) +
geom_bar(stat="identity",
position=position_stackx())
p2 <- ggplot(df, aes(x=trt, y=outcome)) +
geom_bar(stat="identity",
position=position_stackx(vexpand=5))
p3 <- ggplot(df, aes(x=outcome, y=trt)) +
geom_bar(stat="identity",
orientation="y",
position=position_stackx(hexpand=5))
p <- p1 + p2 + p3
p
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.