[R] [ggplot2] Change color of grid lines

Bernd Weiss bernd.weiss at uni-koeln.de
Sun Jun 17 12:01:27 CEST 2007


Hi,

I am making myself familiar with ggplot2 (I really like the examples 
at <http://had.co.nz/ggplot2/>).  

One thing that really annoys me is the default use of white grid 
lines and a gray background [1, 2]. I simply would like to have black 
grid lines and a white background. No problem, I thought, "This is R. 
There is no if. Only how." (fortune("Simon Blomberg")). 

I carfully checked the ggplot2 homepage <http://had.co.nz/ggplot2/> 
and the ggplot2 book <http://had.co.nz/ggplot2/book.pdf>. 

It seemed that the use of ggopt would be a good idea, in particular 
grid.colour. 

library(ggplot2)
x <- rnorm(100)
y <- rnorm(100)
## the default behaviour
(a <- qplot(x,y))
## my attempt to change the default behaviour
ggopt(grid.colour = "black", grid.fill = "white", background.colour = 
"black")
(b <- qplot(x,y))

(Of course, I also gave ggtheme a try but without success.)

Unfortunately, I didn't found any solution for my problem which I 
could hardly believe. I strongly suspect that it's my fault but would 
appreciate any hint like RTFM on page XXX or so. 

Thanks in advance,

Bernd


[1] The red arrows indicate what I mean by "white grid lines" 
<http://www.metaanalyse.de/tmp/ggplot2.png>

[2] I found some reasons why Hadley Wickham prefers the default theme 
at <http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81812.html>, but 
most of our journals reject the use of any gray shading.



More information about the R-help mailing list