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]]
> 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 seeliger.curt@epa.gov 541/754-4638 [[alternative HTML version deleted]]
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 _____________________________________________________ -- View this message in context: http://r.789695.n4.nabble.com/Colors-in-R-tp3665423p3665440.html Sent from the R help mailing list archive at Nabble.com.
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 ...