[R] conditioned xyplot, many y variables

hadley wickham h.wickham at gmail.com
Sun Feb 7 20:49:05 CET 2010

On Sun, Feb 7, 2010 at 11:32 AM, Jacob Wegelin <jacobwegelin at fastmail.fm> wrote:
> The example below creates parallel time-series plots of three different y
> variables conditioned by a dichotomous factor. In the graphical layout,
>        •       Each y variable inhabits its own row and is plotted on its
> own distinct scale.
>        •       Each level of the factor has its own column, but within each
> row the scale is held constant across columns.
>        •       The panels fit tightly (as they do in lattice) without
> superfluous whitespace or ticks.
> Currently I know of no lattice solution to this problem, only a traditional
> graphics solution. Can one solve this problem elegantly using lattice?

It's easy with ggplot2:

JUNKm <- melt(JUNK, measure = c("ppp", "QQQ", "z"))

ggplot(JUNKm, aes(TIME, value, group = ID)) +
  geom_line() +
  geom_point() +
  facet_grid(variable ~ Species, scales = "free_y") +



More information about the R-help mailing list