[R] Plot segments with different colors

Jim Lemon jim at bitwrit.com.au
Tue Nov 13 11:44:03 CET 2007


mysimbaa wrote:
> Hello Everybody,
> I'm trying to plot(x,y) using different colors. 
> I have to cut (x,y) into sub intervals.
> And I want to plot this sub intervals using colors. But infortunally I don't
> know how to do this with R.
> Can any body help me please?
> 
> My code is looking like :
> x<-c(tvar[1:t0],tvar[t0:(ts)],tvar[ts:n])
> F<-c(var[1:t0],var[t0:(ts)],var[ts:n])
> plot(x,F,xlab="Zeit [s]",ylab="Variation [%]",col = "red",type="l")
> 
Hi Adel,
Perhaps you would be interested in the color.scale.lines function in the 
plotrix package that allows one to color each defined segment of a line 
separately.

Jim



More information about the R-help mailing list