[R] [ggplot2] Change color of grid lines

hadley wickham h.wickham at gmail.com
Sun Jun 17 12:36:24 CEST 2007


On 6/17/07, Bernd Weiss <bernd.weiss at uni-koeln.de> wrote:
> 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.

While the structure of ggplot plots is largely complete, I'm still
working on the appearance.  I know a lot of people prefer a white
background with black gridlines (and many journals require it) but it
hasn't been a priority.  It is on my todo list, and hopefully it will
make it in the next release of ggplot (probably 7-10 days from now)

Hadley



More information about the R-help mailing list