I am trying to plot a time series (a stock index) with dates on the x-axis. If I type: plot(a,b) where a is the vector of dates obtained with chron() and b is the time series, I get a nice plot. If I type: plot(a,b,type="l") to obtain the same plot with a continuous line instead of dots, I get the plot of the time series, but the graph is all scattered with numbers (thousands of numbers everywhere!). What is wrong? Is there a better way to get plots with dates on the x-axis? Thank you. Marco Taboga(mtaboga at tiscalinet.it) -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010430/6a61f16b/attachment.html
On Mon, 30 Apr 2001, Marco Taboga wrote:> I am trying to plot a time series (a stock index) with dates on the > x-axis. If I type: plot(a,b) where a is the vector of dates obtained > with chron() and b is the time series, I get a nice plot. If I type: > plot(a,b,type="l") to obtain the same plot with a continuous line > instead of dots, I get the plot of the time series, but the graph is > all scattered with numbers (thousands of numbers everywhere!). What is > wrong? Is there a better way to get plots with dates on the x-axis? > Thank you. >The lines are joined in the order than the points are plotted. This is the order in the dataset, not the order of the x variable. One possibility is oo<-order[a] plot(a[oo],b[oo],type="l") -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I did what you suggested, but nothing changed. I noticed that, if I display the plot without first loading the chron library, the plot is OK, but the dates on the time axis are replaced by sequential numbers. I send you an attachment with the zipped plot, so you can see it. Thank you. Marco Taboga (mtaboga at tiscalinet.it) ----- Original Message ----- From: "Thomas Lumley" <tlumley at u.washington.edu> To: "Marco Taboga" <mtaboga at tiscalinet.it> Cc: <r-help at hypatia.math.ethz.ch> Sent: Monday, April 30, 2001 6:58 PM Subject: Re: [R] Crazy plots of time-series against dates> On Mon, 30 Apr 2001, Marco Taboga wrote: > > > I am trying to plot a time series (a stock index) with dates on the > > x-axis. If I type: plot(a,b) where a is the vector of dates obtained > > with chron() and b is the time series, I get a nice plot. If I type: > > plot(a,b,type="l") to obtain the same plot with a continuous line > > instead of dots, I get the plot of the time series, but the graph is > > all scattered with numbers (thousands of numbers everywhere!). What is > > wrong? Is there a better way to get plots with dates on the x-axis? > > Thank you. > > > > The lines are joined in the order than the points are plotted. This is the > order in the dataset, not the order of the x variable. > > One possibility is > > oo<-order[a] > > plot(a[oo],b[oo],type="l") > > -thomas > > Thomas Lumley Asst. Professor, Biostatistics > tlumley at u.washington.edu University of Washington, Seattle >-------------- next part -------------- A non-text attachment was scrubbed... Name: plot.zip Type: application/x-zip-compressed Size: 27462 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20010501/1bba08ef/plot.bin