I am trying to plot 2 time series on the same graph. 
For example, X1 is the vector of dates and times, its class is POSIXt. Y1 
is an environmental parameter, e.g. salinity. X2 is a second vector of 
dates and times, also of class POSIXt.    X2 has a different length than 
X1, but they have  the exact same range.  Y2 is another environmental 
parameter, e.g. stream flow rate.

My approach is basically like this:
plot(X1,Y1)
par(xaxs = "r")
plot(X1, Y1)
par(new=TRUE)
plot(X2, Y2)

the result is that the date tick marks for the second graph do not exactly 
align with the first graph. This is because the second time series is 
being slightly 'squeezed'; its timescale should match the first graph but 
for some reason R is plotting it on a smaller scale. 
The strange thing is that this doesn't happen for all time series I plot. 
For example X3 and Y3 which have the same basic characteristics as X2 and 
Y2, overlay perfectly with X1 and Y1. I don't know why it works for some 
but not others.

I also tried setting xaxs to "i" -- and had the same outcome. Also had the 
same outcome when trying either  par(xaxs="i") or par(xaxs="r") after the 
command par(new=TRUE)

Any insights would be appreciated

JK
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to