giac
giac

Reputation: 4299

ggplot facet_wrap different themes

I am looking for a way to facet_wrap different themes in the same %>% line, to get something like

enter image description here

Is there any way to do something similar without having to do

fig1 = mtcars %>% filter(am == 1) %>%
  ggplot(aes(wt, mpg)) +
  geom_point() + 
  theme_bw(base_size = 15) + ggtitle('Theme A')

fig2 = mtcars %>% filter(am == 0) %>%
  ggplot(aes(wt, mpg)) +
  geom_point() + 
 theme_minimal(base_size = 15) + ggtitle('Theme B')

grid.arrange(fig1,fig2, ncol = 2)

Is there a way to display different themes for the facet argument in the same line of code?

If not, even just displaying different colour backgrounds for the facet argument will be helpful.

Upvotes: 7

Views: 1274

Answers (1)

Arthur Yip
Arthur Yip

Reputation: 6210

I would think facets are meant to have the same theme (the only thing changing between facets should only be a column that determines which data goes where and the axes based on certain settings free/fixed/etc.).

As @sam81 suggested, this answer is a good hacked solution based on a comment by hadley

Upvotes: 1

Related Questions