[R] Plot segments with different colors

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Tue Nov 13 10:01:20 CET 2007


the 'col' argument of plot() may also be a vector, e.g.,

x <- sort(rnorm(15))
y <- rnorm(15)
plot(x, y,
    col = rep(c("red", "blue", "magenta"), c(5, 6, 4)))


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "mysimbaa" <adel.tekari at sisltd.ch>
To: <r-help at r-project.org>
Sent: Tuesday, November 13, 2007 9:46 AM
Subject: [R] Plot segments with different colors


>
> 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")
>
> Thanks
> -- 
> View this message in context: 
> http://www.nabble.com/Plot-segments-with-different-colors-tf4796466.html#a13721834
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list