The issue in the below code is that there is more than one legend rather than no legend. It would be helpful if that were specified by a different error. (I'm happy to make that simple pull request, if desired.)
library(cowplot)
#> Loading required package: ggplot2
#>
#> Attaching package: 'cowplot'
#> The following object is masked from 'package:ggplot2':
#>
#> ggsave
p <-
ggplot(data.frame(A=1:2), aes(x=A, y=A, colour=A)) +
geom_point()
get_legend(plot_grid(p, p))
#> Error in get_legend(plot_grid(p, p)): Plot must contain a legend
This behavior is correct. Once you’re using plot_grid(), you’re de-facto dealing with a single plot without legend. There are no ggplot2 plots with multiple legends.
The issue in the below code is that there is more than one legend rather than no legend. It would be helpful if that were specified by a different error. (I'm happy to make that simple pull request, if desired.)