아마추어 R 사용자가 여기 있습니다. 이 질문에 답을 얻었는지 묻는 질문이 있지만 나는 좋은 대답을 찾지 못했습니다. 012 "10 평판"이 없기 때문에 이미지를 게시 할 수 없습니다.데이터 프레임의 요소로 스택 막대 플롯 정렬
섭취 경로의 기여도 (내림차순)에 따라 x 변수를 정렬하는 누적 막대 그림이 필요합니다.
Percent<-c(0.4,0.75,0.8, 0.3,0.1,0.6,0.25,0.5)
Inh<-data.frame(ID=c(rep(1,4),rep(2,4)),Age=factor(rep(1:4,2), label=c("0-1 year", "1-2 years", "2-3 years","3-6 years")), Route=factor(rep(1), label="Inhalation"), Percent=Percent)
Ing<-data.frame(ID=c(rep(1,4),rep(2,4)),Age=factor(rep(1:4,2), label=c("0-1 year", "1-2 years", "2-3 years","3-6 years")), Route=factor(rep(1), label="Ingestion"), Percent=1-Percent)
df<-data.frame(rbind(Inh,Ing))
ggplot(df,aes(x=ID,y=Percent,fill=Route))+ geom_bar(stat="identity")+
facet_wrap(~Age, scales = "free_x") +
ylab("Percent Contribution") +
labs(title = "Route Contribution to Exposure by Age Groups")
그러나 나는 내가 수동으로 조롱하는 다음과 같이 할 :
Percent<-c(0.1,0.6,0.25, 0.3,0.4,0.75,0.8,0.5)
Inh<-data.frame(ID=c(rep(1,4),rep(2,4)),Age=factor(rep(1:4,2), label=c("0-1 year", "1-2 years", "2-3 years","3-6 years")), Route=factor(rep(1), label="Inhalation"), Percent=Percent)
Ing<-data.frame(ID=c(rep(1,4),rep(2,4)),Age=factor(rep(1:4,2), label=c("0-1 year", "1-2 years", "2-3 years","3-6 years")), Route=factor(rep(1), label="Ingestion"), Percent=1-Percent)
df<-data.frame(rbind(Inh,Ing))
ggplot(df,aes(x=ID,y=Percent,fill=Route))+ geom_bar(stat="identity")+
facet_wrap(~Age, scales = "free_x") +
ylab("Percent Contribution") +
labs(title = "Route Contribution to Exposure by Age Groups")
사전에 감사합니다!
업데이트 : Roland 덕분에, 나는 음모가 있습니다! 질문은 명확하게 남아 있습니다. 관심이있는 사람들은 여기 코드와 최종 제품의 :이 데이터를 변경하지 않고 순서를 변경
ggplot(df,aes(x=id2,y=Percent,fill=Route, width=1,order = -as.numeric(Route)))+
geom_bar(stat="identity")+
facet_wrap(~Age, scales = "free_x") +
xlab(" ")+
ylab("Percent Contribution") +
theme(axis.text.x = element_blank(), axis.ticks.x= element_blank()) +
labs(title = "DEHP Route Contribution to Exposure by Age Groups")
사진의 경우 링크로 넣을 수 있으며 더 높은 평판을 가진 사람이 추가 할 수 있습니다. – agstudy
이미지 또는 이미지를 온라인에 게재하십시오. 즉, 입력 한 내용과 출력하려고하는 것의 모형. –