调整刻面图的宽度,facet_wrap

问题描述

我可以增加刻面图的整体宽度,以便所有标签都适合吗?或者有什么办法可以防止标签与另一个重叠?


mydata2 <- temperature %>% filter(month == 1 )

mydata2 %>% ggplot(aes(x = year,y = mean_max,color = station_name)) +
  geom_jitter() + 
  facet_wrap(~station_name)

[

My plot1

解决方法

一些选项:

  1. 旋转 x 轴标签:
ggplot() +
theme(axis.text.x = element_text(angle = 45))
  1. 将图例移动到图下方,为刻面创造更多空间:
ggplot() +
theme(legend.position = "bottom")

然后,您还可以决定要在两列中使用图例:

ggplot() +
guides(color = guide_legend(ncol = 2))
  1. 您可以使用 ggsave
  2. 将 ggplot 保存为具有正确大小的 pdf/png