2016-07-25 3 views
1

ggplot2에서 theme()을 사용하는 데 문제가 있습니다. 파란색 플롯 제목과 축 제목에 근무하는 색을 설정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)) 

,하지만 축 텍스트 :

여기 줄거리입니다. 또한 플롯 제목의 크기는 축 텍스트보다 큰 축 제목의 크기보다 크게 유지됩니다. 크기를 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)) 
+0

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – shayaa

답변

1

당신은 테마에서 별도로 모두를 지정할 수는 테마 제목에서 색상을 상속하지 않는 이유는 확실하지, 아마 당신은 버그로 해들리이를 제출할 수 있습니까?

개별적으로 기본 플롯팅 크기에 상대적으로 사물의 크기를 설정하는 것을 선호합니다. 예를 들어, 축 텍스트 및 제목은 일반 텍스트 크기의 두 배입니다. 다른 배율을 선택할 수 있습니다. ?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)))