Paul Roebuck wrote:
Based on reading 'rgb'
So, why are you not using rgb()?
> documentation, I would have thought
the following would have produced identical results. Can someone explain how to make this happen? I need to be able to specify an array of rgb values for the 'col' parameter.
colnames.col <- c("black", "red", "blue", "green") colnames.rgb <- apply(as.matrix(colnames.col), 1, col2rgb) dimnames(colnames.rgb)[[2]] <- colnames.col
baseline <- 1:32 offset2 <- 2*baseline offset3 <- 3*baseline offset4 <- 4*baseline offsets <- cbind(offset2, offset3, offset4)
# Produces expected result X11() matplot(baseline, col = colnames.col[1], type = "l") matlines(offsets, col = colnames.col[-1])
# Displays a ??yellow?? line X11() matplot(baseline, col = as.matrix(colnames.rgb[,1]), type = "l") matlines(offsets, col = colnames.rgb[,-1])
Yes, because 255 is a color number that is interpreted as yellow.
Why do you think you can specify a matrix of integer values and R knows that you mean an rgb representation rather than color numbers?
What you can do now (but I don't think you really want to do it this way!) is:
cn <- apply(colnames.rgb, 2, function(x) rgb(x[1], x[2], x[3], maxColorValue=255))
matplot(baseline, col = cn[1]), type = "l") matlines(offsets, col = cn[-1])
Uwe Ligges
---------------------------------------------------------- SIGSIG -- signature too long (core dumped)
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html