[R] plot a list

Gabor Grothendieck ggrothendieck at gmail.com
Sun Sep 7 03:17:14 CEST 2008


Try xyplot.zoo with scale = list(relation = "free")
specifying xlim as shown below:

library(zoo)
library(lattice)
zm <- do.call(merge, z.l)
xlim <- lapply(zm, function(x) range(time(na.omit(x))))
xyplot(zm, xlim = xlim, scale = list(relation = "free"))

On Sat, Sep 6, 2008 at 7:49 PM, stephen sefick <ssefick at gmail.com> wrote:
> the plot(do.call(merge, z.l)) works on the following data well.  Is
> there a way to get control of xlim so that it plots each individual
> graph shows only the one day (figures the x axis on the range of the
> data for each plot individually) and control labeling?  Thanks in
> advance, and sorry for not putting an example in the first email.
>
> #here is a made up example
> library(chron)
> library(zoo)
> t1 <- chron("1/1/2006", "00:01:00")
> t2 <- chron("1/1/2006", "23:46:00")
> deltat <- times("00:15:00")
> tt <- seq(t1, t2, by = times("00:15:00"))
> DO <- rnorm(96)
> Temp <- rnorm(96)
> a <- cbind(Temp, DO)
>
>
> t3 <- chron("12/1/2006", "00:01:00")
> t4 <- chron("12/1/2006", "23:46:00")
> deltat <- times("00:15:00")
> tt.2 <- seq(t3, t4, by = times("00:15:00"))
> DO.2 <- rnorm(96)
> Temp.2<- rnorm(96)
> b <- cbind(Temp.2, DO.2)
>
> z1 <- zoo(a, tt)
> z2 <- zoo(b, tt.2)
>
> z.l <- list(z1,z2)
> plot(do.call(merge, z.l))
>
> On Sat, Sep 6, 2008 at 7:22 PM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
>> Please read the last line to every message to r-help. In particular
>> this question needs to include a cut down version of the data.
>>
>> I'll take a guess at what it looks like:
>>
>> library(zoo)
>> L <- list(a = zoo(1:3), b = zoo(4:5))
>> plot(do.call(merge, L))
>>
>>
>> On Sat, Sep 6, 2008 at 4:47 PM, stephen sefick <ssefick at gmail.com> wrote:
>>> i have a list of 6 each containing a dataframe of 96 observations as a
>>> zoo object.  Is there a way to plot these in one frame
>>> par(mfrow=c(3,2))
>>>
>>> this is what I tried
>>> lapply(d, FUN=plot)
>>>
>>> I can provide data, list is large.
>>> thanks
>>>
>>> --
>>> Stephen Sefick
>>> Research Scientist
>>> Southeastern Natural Sciences Academy
>>>
>>> Let's not spend our time and resources thinking about things that are
>>> so little or so large that all they really do for us is puff us up and
>>> make us feel like gods. We are mammals, and have not exhausted the
>>> annoying little problems of being mammals.
>>>
>>>        -K. Mullis
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>
>
>
> --
> Stephen Sefick
> Research Scientist
> Southeastern Natural Sciences Academy
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods. We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>        -K. Mullis
>



More information about the R-help mailing list