[R] drawing dot plots with size, shape affecting dot characteristics

Hadley Wickham hadley at rice.edu
Thu Aug 12 20:27:14 CEST 2010


On Wed, Aug 11, 2010 at 10:14 PM, Brian Tsai <btsai00 at 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/



More information about the R-help mailing list