[R] Can R plot multicolor lines?

Petr Pikal petr.pikal at precheza.cz
Fri Jan 6 18:52:34 CET 2006


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 <pdebruic at gmail.com>
To:             	r-help at stat.math.ethz.ch
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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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
petr.pikal at precheza.cz




More information about the R-help mailing list