wilkelab / cowplot

cowplot: Streamlined Plot Theme and Plot Annotations for ggplot2
https://wilkelab.org/cowplot/
701 stars 84 forks source link

ggarange common.legend positioning overwritten #184

Closed cscheeder closed 2 years ago

cscheeder commented 2 years ago

If I run the code below the common legend at the bottom of the combined plot is not centered but left aligned. If I run the code without attaching cowplot the ggarange works as expected. Note: I chose ggarange over grid_arrange for the convenient common.legend option.

library(tidyverse)
library(ggpubr)
library(cowplot)
#> 
#> Attaching package: 'cowplot'
#> The following object is masked from 'package:ggpubr':
#> 
#>     get_legend
theme_set(theme_cowplot())

p1 <- iris %>% 
  ggplot(aes(x=Sepal.Width,y=Petal.Width,color=Species)) + 
  geom_point() + coord_fixed()

p2 <- iris %>% 
  ggplot(aes(x=Sepal.Width,y=Petal.Width,color=Species)) + 
  geom_point() + coord_fixed()

ggarrange(p1,p2,ncol=2,
          labels=c("A","B"),
          common.legend = T,
          legend = "bottom")

Created on 2022-04-12 by the reprex package (v2.0.1)