我知道在创建ggplot图之后,我可以使用theme_get()
返回所有主题元素的详细信息。这对于找出诸如strip.text.x
之类的东西非常有帮助。但我有两件事我想不通:
1)在下面的ggplot图形中,主题项的名称是什么,表示短语“土拨鼠的木头百分比”,因为我想将其调整为更大的字体:
2)如何重新格式化y轴标签以读取10%,20,...而不是.1,.2,......
答案 0 :(得分:7)
对于1),它是$axis.title.y
p + theme(axis.title.x = element_text(size = 25))
其中p
是现有的ggplot对象。
我不知道2)手头。
答案 1 :(得分:4)
对于(2)你想要的是使用formatter
:
dat <- data.frame(x=1:10,y=1:10)
#For ggplot2 0.8.9
ggplot(dat,aes(x = x/10,y=y/10)) +
geom_point() +
scale_x_continuous(formatter = "percent")
#For ggplot2 0.9.0
ggplot(dat,aes(x = x/10,y=y/10)) +
geom_point() +
scale_x_continuous(labels = percent_format())