Hi All,
I need to do a hexbin plot in greyscale for publication. It works fine
in color (working example below), but when I add scale_fill_grey() to
it, it generates an error message. In Googling about on this I found
http://learnr.files.wordpress.com/2009/08/latbook.pdf, which
duplicates Lattice examples in ggplot2, but the hexbin plots from
Lattice are in grey but the author leaves the ggplot2 plots in color.
That makes me wonder if it's possible to do them in grey.
Any ideas?
Thanks,
Bob
# Generate some data:
pretest2 <- round( rnorm( n=5000, mean=80, sd=5) )
posttest2 <- round( pretest2 + rnorm( n=5000, mean=3, sd=3) )
pretest2[pretest2>100] <- 100
posttest2[posttest2>100] <- 100
temp=data.frame(pretest2,posttest2)
# This works fine, but is in color:
ggplot(temp, aes(pretest2, posttest2)) +
geom_hex( bins=30 )
# Adding scale_fill_grey() yields,
# "Error: Continuous variable () supplied to discrete scale_grey."
ggplot(temp, aes(pretest2, posttest2)) +
geom_hex( bins=30 ) + scale_fill_grey()