如何设置自由facet_wrap y轴范围,使其覆盖最大数据点?

时间:2018-10-23 05:30:09

标签: r ggplot2 data-visualization facet-wrap

我有一个facet_wrap图(三个子图),除一件事外,我对所有元素都感到满意:中间和底部图的两个y轴不覆盖最大数据点。

enter image description here

我也不需要固定的y轴,但我希望y轴不被截断。反正有解决此问题的方法吗?

谢谢。

我的代码:

library(ggplot2)
p <- ggplot(df2, aes(x=tmp, y=mean)) +
  geom_point() + 
  facet_wrap(params ~ ., scales="free", nrow = 3,
             strip.position = "left",
             labeller = label_parsed) +
  geom_errorbar(aes(ymax = mean + se, ymin = mean - se, width = 0.12)) +
  theme_bw() +
  theme(strip.background = element_blank(),
        strip.placement = "outside",
        strip.text = element_text(size=10, color="black"),
        panel.grid = element_blank(),
        panel.border = element_blank(),
        axis.line = element_line(size=0.75, colour = "black"),
        axis.ticks.y = element_line(size=0.75, colour = "black"),
        axis.text = element_text(size=10, color="black")) +
  ylab(NULL) + 
  scale_x_continuous("Temperature (°C)", breaks = seq(16.5, 27, by = 1.5), limits = c(16.5, 27))

0 个答案:

没有答案