Skip to content

Backgrounds #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
keithhurley opened this issue Aug 7, 2018 · 7 comments
Closed

Backgrounds #72

keithhurley opened this issue Aug 7, 2018 · 7 comments

Comments

@keithhurley
Copy link

Is it possible to control the "overall" background of the plots. For example, if I use dark backgrounds or transparent backgrounds on the individual plots, the "empty" space on the canvas between individual plots is always white. Is there a way to "theme" the overall canvas?

@ghost
Copy link

ghost commented Sep 25, 2018

I have the exact same question.

Here's a reproducible example

library(tidyverse)
library(patchwork)

df_1 <- tibble(x = c(1:10), y = rnorm(10))
df_2 <- tibble(x = c(1:10), y = rnorm(10))

pl_1 <- df_1 %>% 
  ggplot(aes(x, y))+
  geom_line()+
  geom_point()+
  theme(plot.background = element_rect(fill = 'lightgrey'),
        panel.background = element_rect(fill = 'lightgrey'))+
  labs(title = 'This individual Plot has a grey background')

pl_1

pl_2 <- df_1 %>% 
  ggplot(aes(x, y))+
  geom_line()+
  geom_point()+
  theme(plot.background = element_rect(fill = 'lightgrey'),
        panel.background = element_rect(fill = 'lightgrey'))+
  labs(title = 'Together, the plot background is white')

pl_2 + pl_2

@MattSandy
Copy link

It would be really nice to be able to do this for example

(pl_2 + pl_2) & theme(plot.background = element_rect(fill = "black"))

@modche
Copy link

modche commented Nov 13, 2018

yes, very important!

@krassowski
Copy link

Or event better, allow for watermarks as does cowplot

@thomasp85
Copy link
Owner

& a theme will now also set the theme of the patchwork

@AlinaBW
Copy link

AlinaBW commented Oct 9, 2024

Is is possible to select an entirely transparent background theme for the entire canvas?

@HijaziHassan
Copy link

Is is possible to select an entirely transparent background theme for the entire canvas?

Have you tried this?

& theme(plot.background = element_rect(fill='transparent'),
                legend.background = element_rect(fill = 'transparent')
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants