On Wed, Sep 22, 2010 at 9:56 AM, schaber <kscha...@ipp.mpg.de> wrote: > Hi Jannis, > > thanks a lot for your reply. Unfortunately the solution you proposed does > not work. > Maybe the reason is, that plot.Map only accepts hsv colours and I do not > know to convert the rgb colours to the right colour space. > > Isn't there a possibility to specify minimal an maximal values when using > colorRampPalette to only choose a certain part of the colorRamp(Palette)? I > could than define a new colorset jet.colors2, which is picks out the > colours between min(Vector)/10 and max(Vector)/10? > > jet.colors = colorRampPalette(c("#00007F", "blue", "#007FFF", > "cyan", "#7FFF7F", "yellow", "#FF7F00", > "red", "#7F0000")) > Intervalls <- cut(as.numeric(Matrix[,nc]),n, na.rm=TRUE) } > fgs <- jet.colors(n)[Intervalls] > > Maybe this is a bit confusing...
If you want to control precisely the mapping of numeric values to colours, then you could try my colourschemes package from R-forge: install.packages("colourschemes", repos="http://R-Forge.R-project.org") then you create a function that maps values to colours by, for example, interpolating colours at fixed values, eg: > rs = rampInterpolate ( limits =c(-2 , 2), ramp = c("red", " yellow ", " blue ")) and then: > rs(2) [1] "#0000FFFF" # gives blue > rs(-2) [1] "#FF0000FF" # gives red > rs(0.5) [1] "#BFBF40FF" # nearer yellow than blue so now whatever the range of your data you can just use the rs() function to get the same colours for the same values. > d=data.frame(x=1:10,y=1:10,V1=runif(10,0,2),V2=runif(10,-2,0),V3=runif(10,-2,2)) > plot(d$x,d$y,col=rs(d$V1)) > plot(d$x,d$y,col=rs(d$V2)) > plot(d$x,d$y,col=rs(d$V3)) Barry ______________________________________________ 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.