[R] lattice garphs: combining multiple scatterplots and addinglegend

Bert Gunter gunter.berton at gene.com
Mon Apr 12 19:41:10 CEST 2010

There us no "groups" argument in your xyplot call, so how is auto.key
supposed to define a legend? (and note that auto.key should be a logical not
a list).

Please re-read the auto.key section in the xyplot man page.

Bert Gunter
Genentech Nonclinical Biostatistics
 -----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Jannis
Sent: Monday, April 12, 2010 10:20 AM
To: R-help at r-project.org
Subject: [R] lattice garphs: combining multiple scatterplots and

Dear List members,

its me again, fighting with lattice graphics. I am trying to plot a world
map, add some points on different locations with different colors and add a
legend, but did not succeed yet with the legend. Here is my code:


# Data for demonstration

data_x = c(0,50,60)
data_y = c(0,0,0)
cols   = c(1,2,3)

#print map
all=xyplot(world.dat$y  ~ world.dat$x,
   auto.key = list(x=0,y=0,text=c('test1','test2','test3')))

#add points
update(all,auto.key = list(x=0,y=0,text=c('test1','test2','test3')))

The plots are produced correctly, but the legend is still missing. Could
anyone give me some hints?
There is probably a much more elegant way how to combine the two plots but i
did not manage to understand the usage of these different panel functions.
There is most probably no way around the Trellis book, but I could not yet
buy it....

Thanks for your help

Do You Yahoo!?
Sie sind S

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list