position_stackx: Stack overlapping objects which can be shifted vertically or...

Description Usage Arguments Value Author(s) Examples

View source: R/position_stackx.R

Description

Stack overlapping objects which can be shifted vertically or horizontally

Usage

1
position_stackx(vjust = 1, hexpand = NA, vexpand = NA, reverse = FALSE)

Arguments

vjust

Vertical adjustment for geoms that have a position (like points or lines), not a dimension (like bars or areas). Set to 0 to align with the bottom, 0.5 for the middle, and 1 (the default) for the top.

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 TRUE, will reverse the default stacking order. This is useful if you're rotating both the plot and legend.

Value

position method.

Author(s)

Shuangbin Xu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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

ggtreeExtra documentation built on April 8, 2021, 6:01 p.m.