Re: [R] Multiple series plot with different 'type' argument

From: Dirk Eddelbuettel <edd_at_debian.org>
Date: Mon 25 Jul 2005 - 03:20:05 EST

On 24 July 2005 at 12:03, Dirk Eddelbuettel wrote:
| library(zoo)
|
| ## make up an date index
| index <- Sys.Date() + seq(-99,0,by=1)
|
| ## init random number generato
| set.seed(42)
| ## and create two random series, with the date index
| X1 <- zoo(cumsum(rnorm(100)), index)
| X2 <- zoo(cumsum(rnorm(100)), index)
|
| ## plot series, suppress axes, set limit to range of both series
| oldpar <- par(mar=c(4,4,2,4)) # extra space on the right
| plot(X1, col='blue', ylab="X1", type='l', xaxs="i", ylim=range(X, Y))
| axis(2, col.axis='blue') # y-axis for X1, overplotting
| grid() # prettier
|
| par(new=TRUE) # add to the plot
| plot(X2, col='green', type='l', ylab="", axes=FALSE, xaxs="i", ylim=range(X, Y))
| axis(4, col.axis='green')
| ## need mtext() to annotate 2nd y-axis as title() doesn't do it
| mtext("X2", side=4, line=2)

Oops, the range() calls needs to be range(X1,X2). Sorry!

Dirk  

| Hope this helps, Dirk
|
| --
| Statistics: The (futile) attempt to offer certainty about uncertainty.
| -- Roger Koenker, 'Dictionary of Received Ideas of Statistics'
|
| ______________________________________________
| R-help@stat.math.ethz.ch mailing list
| https://stat.ethz.ch/mailman/listinfo/r-help
| PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Statistics: The (futile) attempt to offer certainty about uncertainty.
         -- Roger Koenker, 'Dictionary of Received Ideas of Statistics'

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Jul 25 03:26:44 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:59 EST