[R] dynamically add items to key of lattice xyplot

From: Bram Kuijper <a.l.w.kuijper_at_rug.nl>
Date: Tue, 05 Feb 2008 10:50:30 +0100


Hi all,

is it possible to dynamically add key items to an already existing key, belonging to a lattice xyplot?

This is what I do: I make an xyplot with an initial key. Later on, I want to extend this key with more items, as more lines are added to the plot (lines are added using trellis.focus("panel")).

I guess I need some function to access the key panel in order to extend it, i.e., by using something like trellis.focus("legend"), but this only yields errors.

Also, in the lattice documentation, the only separate key function I could find is draw.key(), no functions to add individual key items.

anyone has more info on dynamically adding items to keys in xyplots?

thanks,
Bram Kuijper

this is the code for my lattice xyplot plot:

print(xyplot(current_data$FemDiploidUninf ~ current_data$generation, ylim=c(0,2000),
scales=list(x=list(tick.number=4)),
par.settings=list(plot.line=list(col='red')), type="l",
key=list(text=list(c("blah","blah2")),x=0.5,y=0.5,lines=list(type="l",col="red")), ),newpage=FALSE)

# add another line to plot

trellis.focus("panel")
...
trellis.unfocus()

# focus on the existing key

trellis.focus("legend",1,1,highlight=FALSE)

??



R-help_at_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. Received on Tue 05 Feb 2008 - 10:04:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Feb 2008 - 22:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive