|
I have a number of continuous data series I'd like to plot with the
first 2/3 or so of each plotted in one color with the last 1/3 plotted in another color. I've thought of plotting 2 lines that abut each other by determining where the first portion ends and attach the second portion. Is there a simpler way that i have not thought of or discovered through the mailing list, Intro to R, or Lattice PDF? Thanks Paul ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html |
|
Hi
one way is to use segments x<-rnorm(200) plot(1:200, x, type="n") segments(1:199,x[1:199], 2:200, x[2:200], col=c(rep(1,150), rep(2,50))) HTH Petr On 6 Jan 2006 at 12:28, Paul DeBruicker wrote: Date sent: Fri, 6 Jan 2006 12:28:36 -0500 From: Paul DeBruicker <[hidden email]> To: [hidden email] Subject: [R] Can R plot multicolor lines? > I have a number of continuous data series I'd like to plot with the > first 2/3 or so of each plotted in one color with the last 1/3 plotted > in another color. > > I've thought of plotting 2 lines that abut each other by determining > where the first portion ends and attach the second portion. > > > Is there a simpler way that i have not thought of or discovered > through the mailing list, Intro to R, or Lattice PDF? > > Thanks > Paul > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html Petr Pikal [hidden email] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html |
|
In reply to this post by Paul DeBruicker
Try this if you have sort data in ascending order part1x<-x[1:round(2/3*length,digits=0)] part2x<-x[round(2/3*length,digits=0)+1:length(x)] part1y<-y[1:round(2/3*length,digits=0)] part2y<-y[round(2/3*length,digits=0)+1:length(x)] after plot points(part1x,part1y,col="col1",type="l") points(part2x,part2y,col="col2",type="l") --- Paul DeBruicker <[hidden email]> a écrit : > I have a number of continuous data series I'd like > to plot with the > first 2/3 or so of each plotted in one color with > the last 1/3 plotted > in another color. > > I've thought of plotting 2 lines that abut each > other by determining > where the first portion ends and attach the second > portion. > > > Is there a simpler way that i have not thought of or > discovered > through the mailing list, Intro to R, or Lattice > PDF? > > Thanks > Paul > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html |
| Powered by Nabble | Edit this page |
