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]] ______________________________________________ R-help@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.