问题描述
我可以增加刻面图的整体宽度,以便所有标签都适合吗?或者有什么办法可以防止标签与另一个重叠?
mydata2 <- temperature %>% filter(month == 1 )
mydata2 %>% ggplot(aes(x = year,y = mean_max,color = station_name)) +
geom_jitter() +
facet_wrap(~station_name)
[
解决方法
一些选项:
- 旋转 x 轴标签:
ggplot() +
theme(axis.text.x = element_text(angle = 45))
- 将图例移动到图下方,为刻面创造更多空间:
ggplot() +
theme(legend.position = "bottom")
然后,您还可以决定要在两列中使用图例:
ggplot() +
guides(color = guide_legend(ncol = 2))
- 您可以使用
ggsave
将 ggplot 保存为具有正确大小的 pdf/png