[R] Plot.ts

Achim Zeileis zeileis at ci.tuwien.ac.at
Mon Jul 8 13:46:15 CEST 2002


Gavin Simpson wrote:
> 
> Dear list,
> 
> I have a time series of 2-hourly temperature data from loggers placed in
> two lakes.  I have created an object of class ts and mts (temp.ts) using
> the ts() function and have managed to set the start position and the
> frequency to 2-hours.
> 
> I now what to produce a plot of these two time series, and the default
> provided by plot.ts() gives a nice plot of the data for the two lakes in
> two separate panels using the option plot.type="multiple" in plot.ts().
> I would like to alter the plot a little:
> 
> 1) Change the x and y-axis labels, but when I set ylab="" in my call to
> plot.ts() I get the following message:
> 
> >plot.ts(temp.ts, ylab="")
> Error in plot.ts(x[, i], axes = FALSE, xlab = "", ylab = "", log = log,
> :
>         formal argument "ylab" matched by multiple actual arguments
> 
> 2) I get the same when I try to not plot the axes:
> 
> >plot(temp.ts, cex=0.75, axes=FALSE)
> Error in plot.ts(x[, i], axes = FALSE, xlab = "", ylab = "", log = log,
> :
>         formal argument "axes" matched by multiple actual arguments
> 
> 3) I want to change the default labels for the tick marks that the plot
> has ("2000", "2000.5", "2001", "2001.5") to just show the change of
> year, i.e. indicate where 2001 and 2002 start.  But because I do not see
> how to go about not plotting the axes I am a little stuck.

Yes, that is all a little bit tricky, because plot.mts() essentially
sets the 
mfrow parameter to c(2,1) and then sets up 2 different plots. So after
plotting there is also no (nice and simple) way to add something to
these plots with
lines() for example.
Concerning the ylab argument there is a simple (although not elegant)
workaround: plot.mts() takes the colnames() of your mts-object, so you
could change these. But if you want complete control over the axes I
guess the simplest way is to set up the two plots yourself. Look at the
plot.mts() code how it does it.
At least there is no simpler way to do this that I know of...
Z

> Can someone point me in the right direction as to how I can set my own
> y-axis labels for a multiple times series plot, even just setting them
> to "" would be good as I can just use mtext() to add a label for the
> whole plot, and how to specify my own, or control the, labelling of the
> tick marks on the x-axis?
> 
> Many thanks
> 
> Gavin Simpson
> 
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> Gavin Simpson                     [T] +44 (0)20 7679 5522
> ENSIS Research Fellow             [F] +44 (0)20 7679 7565
> ENSIS Ltd. & ECRC                 [E] gavin.simpson at ucl.ac.uk
> UCL Department of Geography       [W] http://www.ucl.ac.uk/~ucfagls/cv/
> 26 Bedford Way                    [W] http://www.ucl.ac.uk/~ucfagls/
> London.  WC1H 0AP.
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list