[R] Problems plotting time-series with multiple lines

Gabor Grothendieck ggrothendieck at gmail.com
Sat Sep 3 05:53:40 CEST 2005

On 9/2/05, Jose Augusto Jr - jamaj - terra <jamaj at terra.com.br> wrote:
> Dear Sirs,
> I want to plot a time series with lines, one for each variable.
> I have a dataset with dates, and the values.
> How can i plot?
> I could plot one variable using index plot, bu i want to put the labels on X
> axis. But i had two problems:
> 1) The plot function, when i try to plot(x,y), incorectly sort the date (on
> X axis). My dataset has the date in string format "%d/%m/%Y).
> If i try to converto to date using
> as.Date(Dataset.dates,"%d/%m/%Y)
> it interprets the %Y incorrectly.

Please provide a reproducible example.

> 2) I have 187 rows. So i have to plot only some of the dates, not all.

Check out plot.Date, lines.Date and axis.Date.
Also plot.zoo in the zoo package may be of use.

More information about the R-help mailing list