changing range of color scale on levelplot

user1308144 picture user1308144 · Jul 16, 2012 · Viewed 11.1k times · Source

I want to do a little tweeking to an image. My command to generate a simple heatmap of correlations is as follows:

psticorr <- cor(psti)
rgb.palette <- colorRampPalette(c("blue", "yellow"), space = "lab")
levelplot(psticorr, col.regions=rgb.palette(120), scales=list(x=list(cex=.3), y=list(cex=.3)), main="PstI: Correlations of loci coverage", xlab="Samples", ylab="Samples" )

I get what I need but I would really like if I could set the range of the color scale e.g from 0 to 1, at the moment it starts at my lowest correlation (r) value.

Answer

Matthew Plourde picture Matthew Plourde · Jul 16, 2012

You can control the color break points in levelplot with the at argument. Try something like at=seq(min(psticorr), max(psticorr), length.out=120)