用facet_wrap在图表上方添加额外的空间

发布于 2025-02-14 01:14:39 字数 597 浏览 2 评论 0原文

我正在尝试将racet_wrap与4个具有不同X轴的图一起使用。我使用了Scales =“ Free”,这很有帮助,但是大多数图都触及了图的顶部。我希望有图表的最高条上方有空间,因此它看起来并不像在图表的极限之上。我希望这是有道理的 - 这是我第一次在这里发布问题。我提供了我拥有的代码和其中一个图形的屏幕截图。如果不使用牛皮地块,我找不到任何解决方案,这比我想要的要高。

代码

wrap_plot <- df  %>% ggplot(aes(x=Race, y = Rate, fill = Sex))+
  geom_col(position = "dodge")+
  labs(x = "Race/Ethnicity",
       y = "Rate per 100,000 population")+
  theme_classic()+
  facet_wrap(~Disease, scales = "free")+
  scale_y_continuous(expand = c(0, 0))

“图片的图片”

I’m trying to use facet_wrap in r with 4 plots that have different x-axis. I used scales = “free” which was helpful, but most of the plots touch the top of the graph. I would like there to be space above the tallest bar of the graph, so it doesn’t look like it’s going off above the limit of the graph. I hope that makes sense - this is my first time posting a question here. I have provided the code that I have and a screenshot of one of the graphs. I haven't been able to find any sort of fix without using cow plot which is a bit more advanced than I would like.

Code:

wrap_plot <- df  %>% ggplot(aes(x=Race, y = Rate, fill = Sex))+
  geom_col(position = "dodge")+
  labs(x = "Race/Ethnicity",
       y = "Rate per 100,000 population")+
  theme_classic()+
  facet_wrap(~Disease, scales = "free")+
  scale_y_continuous(expand = c(0, 0))

Picture of graph

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文