[R] Plotting multiple time series with variables having different units

Rolf Turner r.turner at auckland.ac.nz
Mon Feb 3 00:07:41 CET 2014


Perhaps I misunderstood your question.  Jeff Newmiller says that you did 
not want multiple y-scales on the same plot, which is how I read what 
you wrote.  If you just want plots of X vs. time, Y vs. time, etc.
"stacked" one above the other then you perhaps should simple use 
par(mfrow(.,.)) or perhaps layout().

You could also try using lattice graphics.  Toy example:

require(lattice)
set.seed(42)
junk <- data.frame(x=rnorm(100),time=rep(1:20,5),
                    witch=rep(LETTERS[22:26],each=20))
xyplot(x~time|witch,data=junk,layout=c(1,5,1),type="l",as.table=TRUE)

HTH

cheers,

Rolf Turner


On 03/02/14 10:11, David Parkhurst wrote:
> Don't worry.  I'm also plotting Y against X, which is what really
> matters.  But I want the plots I'm asking about to see how much
> persistence each of those variable has with time.
> Thanks for your warning, however.
> David
>
> On 2/2/2014 3:35 PM, Rolf Turner wrote:
>>
>> Just ***DON'T***!!! Very bad idea; usually wildly misleading.
>> See, e.g.:
>>
>> http://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf
>>
>>
>>
>>
>> OTOH if you're going to be bloody-minded and do it anyway, there are
>> brazillions of hits from a Google search which will tell you how.  But I
>> repeat:  ***DON'T***!!!
>>
>> cheers,
>>
>> Rolf Turner
>>
>> On 03/02/14 08:09, David Parkhurst wrote:
>>> I've tried to figure out how to do this from what I read, but haven't
>>> been successful.  Suppose I have a dataframe with variables Date, X, and
>>> Y (and maybe U, V, and Z) where X, Y, etc. have different units.  I'd
>>> like to plot Y vs. Time above X vs. Time, above one another.
>>>
>>> For example, X is the number of gulls counted on a reservoir, and Y is
>>> the number of coliform bacteria counted on a petri plate from a water
>>> sample leaving the reservoir, so these have very different ranges. U and
>>> V might be numbers of geese and numbers of ducks counted on the same
>>> days.
>>>
>>> What commands would I use to create such a set of plots?
>>




More information about the R-help mailing list