R ggplot2中的文本大小;主题()的问题

R ggplot2中的文本大小;主题()的问题,r,plot,ggplot2,R,Plot,Ggplot2,我在ggplot2中使用主题()时遇到问题 下面是情节: ggplot(data=graph.data, aes(Tree, Proportion)) + geom_bar(stat="identity", fill="black") + geom_errorbar(data=graph.data, mapping=aes(x=Tree, ymin=Proportion-SE, ymax=Proportion+SE), width=0.255) + labs(title="Correcte

我在ggplot2中使用主题()时遇到问题

下面是情节:

ggplot(data=graph.data, aes(Tree, Proportion)) 
+ geom_bar(stat="identity", fill="black") 
+ geom_errorbar(data=graph.data, mapping=aes(x=Tree, ymin=Proportion-SE, ymax=Proportion+SE), width=0.255) 
+ labs(title="Corrected mean LdNPV mortality", x="Tree line", y="Percent mortality") 
+ geom_text(aes(x=Tree, y=Proportion+SE+0.05, label=Letters)) 
+ theme(text=element_text(color="blue", size=12))
将颜色设置为蓝色对打印标题和轴标题有效,但对轴文本无效。此外,绘图标题的大小仍然大于大于轴文本的轴标题的大小。将其增加到size=20会增加打印标题、轴标题和轴文本,但同样不会增加到统一的大小。知道发生了什么事吗

可复制示例:

cities <- c("New York", "Tokyo", "London")
number <- c(20, 50, 35)
letter <- c("a", "b", "ab")
dummy.data <- data.frame(cities, number, letter)
ggplot(data=dummy.data, aes(cities, number)) +
  geom_bar(stat="identity", fill="black") +
  labs(title="Plot title", x="X axis title", y="Y axis title") +
  geom_text(aes(x=cities, y=number+5, label=letter)) + 
  theme(text=element_text(color="blue", size=12))

cities您可以从主题中单独指定所有这些,不确定为什么它没有从主题标题继承颜色,也许您可以将其作为bug提交给Hadley

我更喜欢单独设置事物的大小,并相对于基本打印大小进行设置,例如,轴文本和标题的大小将是常规文本的两倍。你可以选择另一个乘数。您还可以签出
?grid::unit

library(ggplot2)

cities <- c("New York", "Tokyo", "London")
number <- c(20, 50, 35)
letter <- c("a", "b", "ab")
dummy.data <- data.frame(cities, number, letter)
ggplot(data=dummy.data, aes(cities, number)) +
  geom_bar(stat="identity", fill="black") +
  labs(title="Plot title", x="X axis title", y="Y axis title") +
  geom_text(aes(x=cities, y=number+5, label=letter)) + 
  theme(axis.text = element_text(colour = "blue", size = rel(2)),
        title = element_text(color = "red", size = rel(2)))
库(ggplot2)
城市