How to combine 2 plots (ggplot) into one plot?

后端 未结 3 2038
滥情空心
滥情空心 2020-11-30 20:24

By using R, is it possible to place 2 ggplot together (i.e., on the same plot)? I wish to show a trend from 2 different data frames and instead of putting them one next to t

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 20:58

    Just combine them. I think this should work but it's untested:

    p <- ggplot(visual1, aes(ISSUE_DATE,COUNTED)) + geom_point() + 
         geom_smooth(fill="blue", colour="darkblue", size=1)
    
    p <- p + geom_point(data=visual2, aes(ISSUE_DATE,COUNTED)) + 
         geom_smooth(data=visual2, fill="red", colour="red", size=1)
    
    print(p)
    

提交回复
热议问题