complex-upset icon indicating copy to clipboard operation
complex-upset copied to clipboard

How to save the plot with `ggsave`?

Open SdelciLab opened this issue 2 years ago • 1 comments

When I try to add a title above with wrap = T, the ggsave fails

( upset( movies, genres, name='genre', width_ratio=0.1, min_size=10, stripes=c(alpha('grey90', 0.45), alpha('white', 0.3)),wrap = T ) & theme(plot.background=element_rect(fill='transparent', color=NA)) ) ggsave('upset.png', bg="transparent")

SdelciLab avatar Aug 10 '21 10:08 SdelciLab

You need to pass the plot to the ggsave function and then it works perfectly fine:

p = (
    upset(
        movies, genres, name='genre', width_ratio=0.1, min_size=10,
        stripes=c(alpha('grey90', 0.45), alpha('white', 0.3)),
        wrap = T
    )
     & theme(plot.background=element_rect(fill='transparent', color=NA))
)
ggsave('upset.png', p, bg="transparent")

See https://github.com/thomasp85/patchwork/issues/30.

krassowski avatar Aug 10 '21 15:08 krassowski