Align multiple plots in ggplot2 when some have legends and others don't

前端 未结 6 1450
离开以前
离开以前 2020-11-30 03:09

I have used the method indicated here to align graphs sharing the same abscissa.

But I can\'t make it work when some of my graphs have a legend and others don\'t.

6条回答
  •  自闭症患者
    2020-11-30 04:06

    The patchwork package by Thomas Lin Pedersen does this all automagically:

    library(patchwork)
    g1 + g2 + plot_layout(ncol = 1)
    

    Can hardly get any easier than that.

提交回复
热议问题