yanlinlin82/ggvenn

using full plot area

AmelZulji opened this issue · 1 comments

Dear @yanlinlin82,

Thank you for the package!

I have a minor question regarding the plot size. Namely, if you try to align couple of plots using i.e. patchwork it seems like the venn diagrams are not occupying the full plot area.

Following code:

library(ggvenn)
library(patchwork)

a <- list(`Set 1` = c(1, 3, 5, 7, 9),
          `Set 2` = c(1, 5, 9, 13),
          `Set 3` = c(1, 2, 8, 9),
          `Set 4` = c(6, 7, 10, 12))

p1 <- ggvenn(a, c("Set 1", "Set 2"))

p2 <- iris %>% ggplot(aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()

p1 / p2

produces this figure from which it seems like the venn diagrams are not in the full plot area:

Screen Shot 2021-03-18 at 18 07 57

I would expect the plots to occupy full ploting area, like in the example bellow:

p2 / p2

Screen Shot 2021-03-18 at 18 10 56

I tried following:

p1 <- ggvenn(a, c("Set 1", "Set 2")) + theme(plot.margin = unit(c(0,0,0,0), "cm"))

p1/p2

but seems like it has no effect.

Do you have any suggestion how to expend ggvens to occupy full plot area?

Thank you in advance
Amel

@AmelZulji I am so sorry for the quite late reply!

I checked the source code and found some hard-code about the coordinates. Before I fixed this in a better way, here goes a quick workaround:

p1 <- p1 + scale_y_continuous(limits = c(-1, 1.5))
p1 / p2