[R] consolidate legends in ggplot2

Engelmann, Bernd Bernd.Engelmann at amd.com
Thu Feb 7 10:43:55 CET 2008


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 ?

Thank you

Bernd Engelmann 
bernd.engelmann at amd.com
phone: + 49-351-277-4545  
fax: + 49-351-277-9-4545 
AMD Saxony/AMD Saxony Limited Liability Company & Co. KG
M/S E23-TY
Wilschdorfer Landstr. 101 
D-01109 Dresden 
Germany



More information about the R-help mailing list