Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot2 facet_grid() change background-color

Tags:

r

ggplot2

I created a graph like in the image below using facet_grid() to group the different graphs. Now I want to make the graph prettier and want to change the background color of right side. But the only thing I found was opts(strip.text.y = theme_text(hjust = 0)) that can change the color of the text.

So, it is possible to change the background color of the right part? I tried to make it more understandable with the image below.

Best regards!

what I want displayed in an image ;-)

like image 954
Sarah West Avatar asked Feb 25 '11 15:02

Sarah West


1 Answers

Untested, try to change the outline:

+ opts(strip.background = theme_rect(colour = 'purple'))

at the end of your qplot / ggplot2 code. And in case you did not know: this Link to Hadley's reference on github (not documentation) might help.

EDIT:

thanks to Jonathan, I realized the following works, the upper snippet just changes the outline. This one is for the fill:

+ opts(strip.background = theme_rect(fill = 'purple'))

Maybe that has been changed by Hadley?

like image 111
Matt Bannert Avatar answered Oct 17 '22 06:10

Matt Bannert