0
나는 완전히 봤지만,이 질문 만 찾았습니다. "Highlight data individually with facet_grid in R".은 ggplot2의 여러면에 관심있는 영역을 강조 표시합니다.
dt <- data.frame(
a = rep(letters[1:4],each=250),
dirct = rep(c("Up","Down"),500),
term = rep(letters[1:25],400),
logp = runif(1000)
)
ggplot(dt,aes(term,logp,fill=dirct))+
facet_grid(.~a) +
geom_bar(position="dodge",width=0.8,stat="identity")+
scale_fill_manual("dirct",values=c("red","blue"))+
coord_flip()+
theme(axis.text.y=element_text(colour=c(rep("black",10),rep("red",15))))+
geom_rect(aes(xmin=rep(0.5,1000),xmax=rep(10.5,1000),
ymin=-Inf,ymax=Inf),fill="green",alpha=30/200,inherit.aes=FALSE)+
geom_rect(aes(xmin=rep(10.5,1000),xmax=rep(25.5,1000),
ymin=-Inf,ymax=Inf),fill="gray",alpha=30/200,inherit.aes=FALSE)+
geom_vline(aes(xintercept=1:25),color="white") +
geom_hline(aes(yintercept=seq(0,1,0.25)),color="white") +
geom_bar(position="dodge",width=0.8,stat="identity")
여기에서는 여러 패싯에서 영역을 강조 표시하는 방법을 구현했습니다. 내 질문 :
관심 분야를 배경으로 추가 할 수 있습니까? 따라서 다시 그릴 필요가 없습니다. geom_bar
답장을 보내 주셔서 감사합니다!