Skip to content
Prev 163100 / 398500 Next

Line color based on data values?

FWIW

Indeed! And IMHO such a nice example of the power and beauty of the R
language.

-- Bert

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Greg Snow
Sent: Tuesday, November 25, 2008 10:00 AM
To: Rory.WINSTON at rbs.com; r-help at r-project.org
Subject: Re: [R] Line color based on data values?

Try this:

tmp <- with(iris, seq( min(Petal.Length)-1, max(Petal.Length)+1,
length.out=6))
with( iris, plot( Sepal.Width, Sepal.Length, col=topo.colors(5)[
cut(Petal.Length,tmp) ] ) )

hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
______________________________________________
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.