我尝试使用+opts(subtitle="text")
添加小标题,但没有显示出来。主标题确实有效(+opts(title="text")
)。如何添加小标题并更改R中ggplot图的字体大小?
我还想为轴(标签和坐标)使用较大的字体,但我不知道该怎么做。
我尝试使用+opts(subtitle="text")
添加小标题,但没有显示出来。主标题确实有效(+opts(title="text")
)。如何添加小标题并更改R中ggplot图的字体大小?
我还想为轴(标签和坐标)使用较大的字体,但我不知道该怎么做。
theme_get()
会告诉你,你可以在opts()
使用 “隐藏” 选项,张贴0.91这是theme()
电流:
theme(axis.text.x=element_text(size=X))
theme(axis.text.y=element_text(size=X))
前0.91:
opts(axis.text.x=theme_text(size=X))
opts(axis.text.y=theme_text(size=X))
将尺寸更改为您所需的尺寸。
WRT标题,您可以使用 “\ n” 来剩余的文本移动到新行:
电流:
labs(title="text \n more text")
前0.91:
opts(title="text \n more text")
ggplot2没有“字幕”功能。但是,您可以使用任何标签中的\ n项来删除一行。
更新:ggplot版本2.2.0可以做字幕,如例如,在this blog post。
例子:
library(ggplot2)
packageVersion("ggplot2") ## 2.2.0
d <- data.frame(x=1:5,y=1:5)
ggplot(d,aes(x,y))+
labs(title="abc",subtitle="def")+
## default left-aligned: moved them to center alignment
theme(plot.title=element_text(hjust=0.5),
plot.subtitle=element_text(hjust=0.5))
对于第一个问题,有一个更好的答案在这里:http://stackoverflow.com/questions/11724311/how-to-add-a-ggplot2 -subtitle-with-different-size-and-color – naught101 2014-08-29 02:51:41
将问题标记为重复的,因为有一个更新的问题对我来说看起来很奇怪。那么为什么这被标记为重复? – Jaap 2014-08-29 08:35:07