5

I'm struggling to plot a gradient color scale for each facet in facet_wrap() independently. Data is too big to post it here but here is my code:

ggplot(stack, aes(hour, day)) + 
  geom_tile(aes(fill = percent), colour = "white") + 
  facet_wrap(~author, ncol = 3) +
  theme_minimal() +
  scale_fill_distiller(palette = 'RdYlBu') +
  theme(
    axis.title.x = element_blank(), axis.title.y = element_blank(),
    legend.position = "none",
    strip.background = element_rect(fill = '#E5E6E1'),
    strip.text = element_text(face = 'bold')
  )

enter image description here

However, if I plot individually only one author, I get:

enter image description here

I just wanna plot each facet with its own gradient color scale, not share with the rest of the facets. Should be very simple, but I don't manage to do it. I tried adding group = author within aes() in geom_tile() and ggplot() but it wouldn't work.

markus
  • 25,843
  • 5
  • 39
  • 58
piblo95
  • 123
  • 1
  • 2
  • 10

1 Answers1

2

After much research, I ended up using the solution provided here that uses gridExtra. I guess there is no easy way to do it using only ggplot.

piblo95
  • 123
  • 1
  • 2
  • 10