[R] consolidate legends in ggplot2

hadley wickham h.wickham at gmail.com
Thu Feb 7 15:10:53 CET 2008


On Feb 7, 2008 3:43 AM, Engelmann, Bernd <Bernd.Engelmann at amd.com> wrote:
> Hello,
>
> the same parameter for colour and shape aesthetics gives 2 legends:
>
> library(ggplot2)
> p <- ggplot(mtcars, aes(x=wt, y=mpg))
> p + geom_point(aes(colour=factor(cyl), shape=factor(cyl)))
>
> Can the 2 legends be consolidated to one with
> colours and shapes of the symbols matched between legend and plot ?

Not in the current version of ggplot2, but I'm working on that code in
the development version at the moment and it will be included in the
next version.  If your real example is more complicated than that,
please let me know so that I can check if my code works.

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list