在包含许多面板的图中使用facet_wrap和ggsave

时间:2017-11-23 01:33:04

标签: r ggplot2

我试图为第三个分类变量的几个值(大约350)生成两个变量的散点图。这是我目前的代码:

my.plot <- ggplot(aes(x=first_variable, y=second_variable, color=fourth_variable), data=my.data) + 
           geom_point() +
           facet_wrap(~ third_variable, scales = 'free')
ggsave(filename='test_plot.jpg', plot=my.plot, width=20, height=20, units='in', limitsize=FALSE)

但是,保存的图形的字体相对于倾斜和压缩的绘图区域而言太大了。有没有办法可以缩小每个面板的整个内容,字体和所有内容,以避免重叠并在保存的文件中获得好的图?

这是图中的两个样本。

enter image description here enter image description here

1 个答案:

答案 0 :(得分:1)

您可以尝试使用+ theme(text = element_text(size = 10))之类的内容缩小所有文字的大小,或者查看theme的元素,为更具体的元素设置文字大小。