[R] [ggplot2] Change color of grid lines

From: Bernd Weiss <bernd.weiss_at_uni-koeln.de>
Date: Sun, 17 Jun 2007 12:01:27 +0200


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.

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,


[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.

R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 17 Jun 2007 - 10:13:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 17 Jun 2007 - 11:32:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.