Re: [R] dynamically add items to key of lattice xyplot

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue, 5 Feb 2008 16:12:53 -0600

On Feb 5, 2008 3:50 AM, Bram Kuijper <a.l.w.kuijper_at_rug.nl> wrote:
> Hi all,
>
> is it possible to dynamically add key items to an already existing key,
> belonging to a lattice xyplot?

It's not lattice, but this is pretty easy to do with ggplot2:

install.packages("ggplot2")
library(ggplot2)

qplot(mpg, wt, data=mtcars, colour="1") + geom_point(aes(x = mpg ^ 2, colour="2")) + geom_point(aes(x=mpg^3, colour="3")) +
scale_colour_discrete("x power")

each time you add a new layer, all of the scale limits are recalculated to ensure that all data is displayed. You can read more about ggplot2 at http://had.co.nz/ggplot2

Hadley

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

______________________________________________
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 - 22:16:33 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