oj 섹션에서만 작동하는 "annotate function"다음 코드를 어떻게 수정할 수 있습니까? 내 말은 (setosa.VC 및 versicolor.VC)
data("ToothGrowth")
data('iris')
iris2<-iris[c(1:10,50:60,100:110,61:70,11:20,111:118),]
big_data<-cbind(iris2,ToothGrowth) #dummy data
big_data$com <- with(big_data, interaction(Species,supp), drop = TRUE)
big_data$N <- 4
big_data$label <- paste0(big_data$com,"\n","(n=",big_data$N,")")
plot<- ggplot(big_data, aes(label, len))+geom_boxplot()+facet_wrap(~supp, scales = "free_x")
plot<- plot + annotate("rect", xmin = 1, xmax = 2, ymin = 35, ymax =35, alpha=1,colour = "black")+
annotate("rect", xmin = 1, xmax = 1, ymin = 33, ymax =35, alpha=1, colour = "black")+
annotate("rect", xmin = 2, xmax = 2, ymin = 33, ymax =35, alpha=1,colour = "black")
데이터 섹션에 facet_wrap
직사각형을 플로팅하도록 속일 수 있습니다 .OJ
subset
ggplot(big_data, aes(label, len)) +
geom_boxplot() +
facet_wrap(~supp, scales = "free_x") +
geom_rect(data= subset(big_data, supp=="OJ"),
aes(xmin=1, xmax=2, ymin=35, ymax=35), alpha=1, colour="black") +
geom_rect(data= subset(big_data, supp=="OJ"),
aes(xmin=1, xmax=1, ymin=33, ymax=35), alpha=1, colour="black") +
geom_rect(data= subset(big_data, supp=="OJ"),
aes(xmin=2, xmax=2, ymin=33, ymax=35), alpha=1, colour="black")
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다