Hav11 Hav11 - 3 months ago 7
R Question

ggplot2: How do you change the colour of the background of the wsj theme?

I'm guessing that it is probably really easy, but I can't figure out how to change the background colour of the graph I made with

ggplot(...) + geom_line(...) + theme_wsj()
. It is now kind of yellowish and I would like to have it white.

I tried

+ theme_wsj(panel.background = theme_rect(fill = "white"))


but that gave an error :unused argument (panel.background = theme_rect(fill = "white"))

Answer

Try argument named panel.background inside theme() function and not theme_wsj(). An example is shown below

    + theme(panel.background = element_rect(fill = "navy"))