Colors in R

classic Classic list List threaded Threaded
4 messages Options
lt2
Reply | Threaded
Open this post in threaded view
|

Colors in R

lt2
HI everyone,
I'm trying to assign colors to multiple lines in a graph. Problem is I don't want to type in as many colors as there are lines....is there a way around this? In brief, I'm plotting the logratio for up to 60 samples and want a different color for each sample.  Here is the code I'm using now..

Any help is greatly appreciated..

Best

LT

data <- read.table("data.csv", header=T, sep=",", stringsAsFactors= F)

data$Pt <-as.numeric(data$Pt)
npts <- unique(data$Pt)

xrange = c(min(data$Coordinate), max(data$Coordinate))
yrange = c(min(data$Log2Ratio), max(data$Log2Ratio))



 colors <-c("red","blue","green","darkmagenta","darkgreen","darkorange","darkred","gold","midnightblue","seagreen1","tomato","slateblue","violet","purple4","palegreen","darkviolet","forestgreen","firebrick"...up to 60 colors)

labels <- c('a','b', 'c', 'd', 'e', up to 60 labels)

#add lines
for (i in 1:length(npts)) {
     color=colors[i]
     pt = data[data$Pt==npts[i],]; plot(pt$Coordinate, pt$Log2Ratio, type="l", lty=3,col=color, xlim=xrange, ylim=yrange); par(new=T)}

        [[alternative HTML version deleted]]

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Colors in R

Curt Seeliger
> I'm trying to assign colors to multiple lines in a graph. Problem is
> I don't want to type in as many colors as there are lines....

You'll find your answer over the ?rainbow, I bet.

cur
--
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
[hidden email]
541/754-4638

        [[alternative HTML version deleted]]

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Colors in R

Arun.stat
In reply to this post by lt2
may be this is of some help

http://research.stowers-institute.org/efg/R/Color/Chart/
_____________________________________________________

Arun Kumar Saha, FRM
QUANTITATIVE RISK AND HEDGE CONSULTING SPECIALIST
Visit me at: http://in.linkedin.com/in/ArunFRM
_____________________________________________________

Reply | Threaded
Open this post in threaded view
|

Re: Colors in R

bbolker
In reply to this post by lt2
Trevino, Lisa <lt2 <at> bcm.edu> writes:

> I'm trying to assign colors to multiple lines in a graph.
>  Problem is I don't want to type in as many colors as
> there are lines....is there a way around this? In brief,
> I'm plotting the logratio for up to 60 samples and
> want a different color for each sample.  

  See my answer to

  http://stackoverflow.com/questions/6075140/
in-r-how-do-i-change-the-color-value-of-just-one-value-
in-ggplot2s-scale-fill-br/6076605#6076605

  (line-broken URL to make Gmane happy: reassemble it)

 The bottom line is that you *can* do this, but you will
also have to live with the fact that you will not actually be
able to distinguish among the colours unless you are superhuman
and using a very good output channel ...

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.