[R] Drawing rectangles in multiple panels

hadley wickham h.wickham at gmail.com
Wed Jul 11 20:08:32 CEST 2007


> A question/comment: I have usually found that the subscripts argument is
> what I need when passing *external* information into the panel function, for
> example, when I wish to add results from a fit done external to the trellis
> call. Fits[subscripts] gives me the fits (or whatever) I want to plot for
> each panel. It is not clear to me how the panel layout information from
> panel.number(), etc. would be helpful here instead. Am I correct? -- or is
> there a smarter way to do this that I've missed?

This is one of things that I think ggplot does better - it's much
easier to plot multiple data sources.  I don't have many examples of
this yet, but the final example on
http://had.co.nz/ggplot2/geom_abline.html illustrates the basic idea.

For the original poster ggplot2 isn't that much more convenient,
because there isn't a built in rectangle geom (although it would be
trivial to add one).  You could use the more general polygon geom,
http://had.co.nz/ggplot2/geom_polygon.html, however it currently
doesn't have a lot of documentation.

Hadley



More information about the R-help mailing list