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

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Sun Feb 2 22:32:13 CET 2014


He did not ask for dual axis graphs, Rolf.

This can be done with lattice graphics and also with ggplot. See, for example, [1] or [2]. The melt function is a very powerful tool for preparing for this task.

[1] http://www.fromthebottomoftheheap.net/2013/10/23/time-series-plots-with-lattice-and-ggplot/
[2] http://learnr.wordpress.com/2009/05/18/ggplot2-three-variable-time-series-panel-chart/
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On February 2, 2014 12:35:19 PM PST, Rolf Turner <r.turner at auckland.ac.nz> 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?
>
>______________________________________________
>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.




More information about the R-help mailing list