[英]Set Legend Spacing in ggplot2
I am trying to create a plot in R using ggplot2. 我正在尝试使用ggplot2在R中创建图。 The figure looks great when displayed in R, but when I write it to pdf the labels in the legend slightly overlap the different color lines they are defining.
当以R显示时,该图看起来很棒,但是当我将其写为pdf时,图例中的标签稍微重叠了它们所定义的不同色线。 How do I add white space between entries so that this does not happen?
如何在条目之间添加空格,以免发生这种情况?
Without code example it is hard to say, but if you don't see this problem in the R display and you see it in the pdf, you can try to increase the pdf output size. 没有代码示例,这很难说,但是如果您在R显示器中看不到此问题,而在pdf中看到它,则可以尝试增加pdf输出的大小。 When rendering a pdf, the font size is kept and the elements of the graph are more squeezed if the output size is smaller than the displayed one.
呈现pdf时,如果输出大小小于显示的大小,则将保留字体大小,并进一步压缩图形的元素。
p<-ggplot(mpg,aes(cyl,year))+geom_point()
ggsave('yourfile.pdf',p,width=10,height=10) # default is 7 on my install
I don't know if it is possible to change the spacing, but I don't see any parameters for that in the theme()
or element_text()
documentation 我不知道是否可以更改间距,但是在
theme()
或element_text()
文档中看不到任何参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.