저는 X 축에 두 가지 다른 요인으로 분류 된 R-cran에서 박스 플롯을 만들기 위해 노력하고 있습니다. 내 문제는 단지 2 ~ 3 레벨을 가진 두 번째 요소에 레이블을 붙이는 범례를 사용하면서 전체 그래프를 적절하게 스팬하는 +20 레벨의 한 요소에 대한 레이블을 만드는 데 있습니다. 여기 다중 팩터 라벨이있는 R 박스 플롯
는 테스트 스크립트입니다 약을 흉내 내 실제 데이터 세트 : 어떤 도움d<-data.frame(x=rnorm(1500),f1=rep(seq(1:20),75),f2=rep(letters[1:3],500))
# first factor has 20+ levels
d$f1<-factor(d$f1)
# second factor a,b,c
d$f2<-factor(d$f2)
boxplot(x~f2*f1,data=d,col=c("red","blue","green"),frame.plot=TRUE,axes=FALSE)
# y axis is numeric and works fine
yts=pretty(d$x,n=5)
axis(2,yts)
# I know this doesn't work; what I'd like is to spread the factors out
# so the each group of three(a,b,c) is labeled correctly
axis(1,at=seq(1:20))
# Use the legend to handle the f2 factor labels
legend(1, max(d$x), c("a", "b","c"),fill = c("red", "blue","green"))
감사
'ggplot'이라는 음모를 꾸밀 수 있다는 것을 결코 깨닫지 못했습니다! 나는 못생긴 회색 배경 때문에 항상 사용하지 않았다. 보여 주셔서 고마워요. – thelatemail
@thelatemail, themeing을 사용하면 플롯의 거의 모든 요소를 조정/수정할 수 있습니다. –
@thelatemail - 주제에 대한 개요는 [here] (https://github.com/hadley/ggplot2/wiki/Themes)를 참조하십시오. – Chase