# What is an elegant way of visualising two time series with many data points?

I need to draw two time-series plots on a graph in R. The problem I am facing is as follows. Each plot has 200 data points, and therefore, the graph that I have produced looks clumsy on my two-column pdf file. I am trying to use different pch values, but still the graph doesn't look good to me. Could someone help me to visualize this data in an elegant way, please? Please see the graph below. The most important requirement is that the graph should be clear on printing.

The R Code that I have used is as follows:

plot(temp11, type="b", col="blue", ylim=c(0.5,1), lwd=0.8, lty=4, pch=1, xlab="Time", ylab="price", cex.lab=1.2,cex.axis=1.2)
> lines(temp22, type="b", col="red", lwd=1.5,lty=1, pch=18)
> legend("top",legend=c("temp11","temp22"),lty=c(4,1),pch=c(1,18), col=c("blue", "red"),text.col=c("blue", "red"))


-
maybe losing the plotting characters altogether and increasing the line width (argument: lwd. takes positive real values) would made it reasonable. How does this example x=ts(rnorm(100)); y=ts(rnorm(100)); plot(x, col=2, ylim=c(-4,4), lwd=4); lines(y, col=4, lwd=4) look? It would need to be suped-up a bit but I think that basic template makes both time series visible. –  Macro Aug 28 '11 at 3:56
@Marco: Thanks. On a computer screen your idea is perfectly fine. But the graph should be elagant on printing. It would be great if you share your ideas further on this. –  samarasa Aug 28 '11 at 4:02
Have you thought about two rows instead of two columns? Even if you decide to keep them both on the same axes, if you'd make your height smaller than your width then it'd stretch the series out to address that bunching up shown above. –  G. Jay Kerns Aug 28 '11 at 5:29
@Jay: I am not getting your idea. Could you please give more information? Thank you. –  samarasa Aug 28 '11 at 6:04
As @macro suggested, maybe lose the points altogether, or maybe just make them really small. You could use cex = .3, or pch = '.'. If you make them small,I would suggest filled circles instead of open circles. Given the overlap on the right side of the graph, though, it might be good to lose the lines and keep the dots, perhaps with a small amount of jitter to avoid overlap –  Peter Flom Aug 28 '11 at 10:37

Partial transparency ("alpha") might help you here, e.g.:

> temp11=runif(100)
> temp22=runif(100)
> plot(temp11, type="p", col=rgb(0.2, 0.2, 1, 0.6), pch=19, xlab="Time", ylab="price")
> lines(temp11, lwd=3, col=rgb(0.2, 0.2, 1, 0.3))
> points(temp22, pch=19, col=rgb(1, 0.2, 0.2, 0.6))
> lines(temp22, lwd=3, col=rgb(1, 0.2, 0.2, 0.3))


Here is an example of the image:

It doesn't look that great with runif data, but on your data I think it would work a bit better. Alpha support is device-dependent, but PDF does support it.

-
Welcome to the site. With your couple of upvotes from this post you should have enough reputation to post as many images and links in questions/answers as you would like. –  Andy W Aug 28 '11 at 21:08

Here's what I was trying to say in the comment, with a little bit more detail (though this might not be the answer to your question). First, get some data.

x <- arima.sim(200, model = list(ar = 0.6)) + 3
y <- arima.sim(200, model = list(ar = -0.7)) - 3


A plot with two columns would look something like this:

par(mfrow = c(1,2))
plot(x)
plot(y)


with a graph like so:

while a plot with two rows would look something like this:

par(mfrow = c(2,1))
plot(x)
plot(y)


with a graph like so:

And if you'd like to keep both series on the same axes then you could do like this:

par(mfrow = c(1,1))
ts.plot(x, y)


which would look something like this:

I was trying to communicate that if you make the plot wider rather than taller then it helps to see what's happening inside the lengthy time series better. You can manually resize the graphics device to get the aspect you like, or if you use RStudio, when you export the image you can set whatever dimensions desired.

-