Paul Johnson
2000-Aug-09 19:59 UTC
[R] Trying to make plot of several time series in same graph
Dear Friends in R: On RedHat linux, R-1.1, I've gotten far enough to create the graph that shows on the screen with 3 lines, but I have some trouble. Here is the way I created the three "overlaid" graphs: data<-read.table("DataCulture0",header=T,as.is = TRUE) attach(data) tmp1<-plot(acquaint~T,type='l', ylim=c(0,1),ylab="average proportion",xlab="PERIOD",xlim=c(1,6000),lty=1,pch=1,main="") par("new"=TRUE) tmp2<-plot(harmony~T,type='l', ylim=c(0,1),ylab="average proportion",xlab="PERIOD",xlim=c(1,6000),lty=2,pch=1,main="") par("new"=TRUE) tmp3<-plot(identical~T,type='l', ylim=c(0,1),ylab="average proportion",xlab="PERIOD",xlim=c(1,6000),lty=3,pch=1,main="") Problems. 1. I want to label each line that is plotted on the graph. Is there a non interactive way to do it? My coauthor uses S+ and he used a sequence of commands like this: identify.xyplot(tmp1,labels=acq,n=1,adj=0) But I don't think it is exactly what I want. 2. When I run the code above, the screen shows 3 lines with different line styles. IF I start over again with> postscript("../output.ps")and then run the commands again, and then> dev.off()null device 1 In the ps file that is saved, all of the lines look the same. I used the Gimp to take a "screenshot" of the figure as it looks in R: http://lark.cc.ukans.edu/~pauljohn/exampleRGraph.gif And the postscript output looks like this: http://lark.cc.ukans.edu/~pauljohn/exampleRGraph.ps Any help in saving graphs would be appreciated. I feel totally clueless, and I've been looking pretty hard in the V&R and R-intro. 3. In light of difficulty with line styles, I experimented with character options with type='o' and various pch=x. Those pictures looked terrible because the symbols were all too dense. I guess I need something to print every 100th point there? -- Paul E. Johnson email: pauljohn at ukans.edu Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn University of Kansas Office: (785) 864-9086 Lawrence, Kansas 66045 FAX: (785) 864-5700 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Yesterday I asked about saved ps files not being the same as screen appearance. Today I've just discovered the problem is in gv, the ps viewer, rather than R, because I can print those R-outputted ps files on the printer and they look fine. In addition, I downloaded the Gnome viewer "ggv" and it shows the lines as they ought to be. I'm still trying to configure this output the way I need it. If somebody has a relatively full-featured example of a program with a graph with lots of separate things on it, I could probably figure what I need from that. I keep getting stuck on all these little details, like trying to set the legend for the separate lines or controlling the paper size of the postscript output. Thanks in advance. Paul Johnson wrote:> With R-1.1, RH Linux 6.2, I created the three "overlaid" graphs: > > data<-read.table("DataCulture0",header=T,as.is = TRUE) > attach(data) > tmp1<-plot(acquaint~T,type='l', ylim=c(0,1),ylab="average > proportion",xlab="PERIOD",xlim=c(1,6000),lty=1,pch=1,main="") > par("new"=TRUE) > tmp2<-plot(harmony~T,type='l', ylim=c(0,1),ylab="average > proportion",xlab="PERIOD",xlim=c(1,6000),lty=2,pch=1,main="") > par("new"=TRUE) > tmp3<-plot(identical~T,type='l', ylim=c(0,1),ylab="average > proportion",xlab="PERIOD",xlim=c(1,6000),lty=3,pch=1,main="") > > Problems. > 1. I want to label each line that is plotted on the graph. Is there a > non interactive way to do it? My coauthor uses S+ and he used a > sequence of commands like this: > identify.xyplot(tmp1,labels=acq,n=1,adj=0) > But I don't think it is exactly what I want. > > 2. When I run the code above, the screen shows 3 lines with different > line styles. IF I start over again with > > postscript("../output.ps") > and then run the commands again, and then > > dev.off() > null device > 1 > In the ps file that is saved, all of the lines look the same. > > I used the Gimp to take a "screenshot" of the figure as it looks in R: > > http://lark.cc.ukans.edu/~pauljohn/exampleRGraph.gif > > And the postscript output looks like this: > > http://lark.cc.ukans.edu/~pauljohn/exampleRGraph.ps > > Any help in saving graphs would be appreciated. I feel totally > clueless, and I've been looking pretty hard in the V&R and R-intro. > > 3. In light of difficulty with line styles, I experimented with > character options with type='o' and various pch=x. Those pictures looked > terrible because the symbols were all too dense. I guess I need > something to print every 100th point there? > > ---- Paul E. Johnson email: pauljohn at ukans.edu Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn University of Kansas Office: (785) 864-9086 Lawrence, Kansas 66045 FAX: (785) 864-5700 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._