-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
It is very usefult that the limits argument scale_*_continuous and scale_*_binned functions can accept a function.
It'd be great if xlim and ylim could do this as well
library(tidyverse)
d <- data.frame(
trt = factor(c(1, 1, 2, 2)),
resp = c(1, 5, 3, 4),
group = factor(c(1, 2, 1, 2)),
upper = c(1.1, 5.3, 3.3, 4.2),
lower = c(0.8, 4.6, 2.4, 3.6)
)
d |>
ggplot() +
geom_linerange(
aes(y = trt,
x = resp,
colour = group,
xmin = lower,
xmax = upper),
position = position_dodge(width = 0.2),
)
#works
p +
xlim(c(0, 5))
#doesn't
p +
xlim(\(x) range(x, 0))
Metadata
Metadata
Assignees
Labels
No labels