기타
[R] ggplot 합치기 / plot 이어붙이기 / 그래프 합치기
메리짱123
2021. 10. 15. 08:52
반응형
따로따로 그린 그래프를 말그대로 밑이든 옆이든 이어붙이기
patchwork library 필요
library(patchwork)
두 개의 그래프가 있다.
pm2.5plot<-ggplot(tsv,aes(x=date,y=PM2.5, colour=기기이름,group=기기이름))+
geom_line()+
theme(legend.position="none", legend.box="vertical")+
facet_wrap(~"PM2.5",ncol = 1,scales="free")
pm10plot<-ggplot(tsv,aes(x=date,y=PM10, colour=기기이름,group=기기이름))+
geom_line()+
theme(legend.position="bottom", legend.box="vertical")+
facet_wrap(~"PM10",ncol = 1,scales="free")
1. 위아래로 붙이기
위 그래프 / 아래 그래프
pm2.5plot/pm10plot
2. 좌우로 붙이기
좌 그래프 + 우 그래프
pm2.5plot+pm10plot
반응형