[R] drawing dot plots with size, shape affecting dot characteristics
Hi all, I'm interested in doing a dot plot where *both* the size and color (more specifically, shade of grey) change with the associated value. I've found examples online for ggplot2 where you can scale the size of the dot with a value: http://had.co.nz/ggplot2/graphics/6a053f23cf5bdfe5155ab53d345a5e0b.png Or scale the color with the value: http://had.co.nz/ggplot2/graphics/b17bf93530ff6695afb366e65677c17f.png both of which are from here: http://had.co.nz/ggplot2/geom_point.html but I've been playing around with ggplot2 and couldn't figure out how to do both at the same time - ideally i want size to increase with a value, and the shade of grey to get lighter with increasing value. Any help's appreciated, thanks! Brian [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] drawing dot plots with size, shape affecting dot characteristics
Try running this and see if it does what you want. It just uses plain old plot with the cex arg for size and the col arg for colour... greyDots - function() { # make up some data x - runif(50, 0, 10) y - runif(50, 0, 10) valueMax - 100 value - sample(valueMax, 50) # edit these to taste maxDotSize - 5 maxGreyLevel - 0.8 plot(x, y, pch=16, xlim=c(0,10), ylim=c(0,10), cex=maxDotSize * value / valueMax, col=grey(maxGreyLevel * value / valueMax)) } On 12 August 2010 13:14, Brian Tsai btsa...@gmail.com wrote: Hi all, I'm interested in doing a dot plot where *both* the size and color (more specifically, shade of grey) change with the associated value. __ R-help@r-project.org 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.
Re: [R] drawing dot plots with size, shape affecting dot characteristics
On Wed, Aug 11, 2010 at 10:14 PM, Brian Tsai btsa...@gmail.com wrote: Hi all, I'm interested in doing a dot plot where *both* the size and color (more specifically, shade of grey) change with the associated value. I've found examples online for ggplot2 where you can scale the size of the dot with a value: http://had.co.nz/ggplot2/graphics/6a053f23cf5bdfe5155ab53d345a5e0b.png Or scale the color with the value: http://had.co.nz/ggplot2/graphics/b17bf93530ff6695afb366e65677c17f.png both of which are from here: http://had.co.nz/ggplot2/geom_point.html but I've been playing around with ggplot2 and couldn't figure out how to do both at the same time - ideally i want size to increase with a value, and the shade of grey to get lighter with increasing value. qplot(mpg, wt, data = mtcars, colour = qsec, size = qsec) + scale_colour_grey() Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-help@r-project.org 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.