I am using R lattice()
to make a 3D wireframe plot. The color scale for the surface ranges from -0.6 to +0.2. I created a blue-white-red color gradient scheme with:
bwr.colors <- colorRampPalette(c("blue, "white", "red"))
and am creating the plot like so:
gca_plot <- wireframe(dev ~ col*row, data=gca,
xlab = "col",
xlim = c(1, 24),
ylab = "row",
ylim = c(9, -6),
zlim=c(-0.6, 0.2),
main = "GCA",
drape = TRUE,
colorkey = TRUE,
at=do.breaks(c(-0.6,0.2),100),
scales = list(arrows=FALSE,cex=.5, tick.number = 10, z = list(arrows=F), distance =c(1.5, 1.5, 1.5)),
col.regions = bwr.colors(100),
screen = list(z = 30, x = -60))
The problem is that I'd like to center color (white) to be at zero since this is a deviation plot. I want red values > 0 and blue < 0.
I know that making my scale run from -0.6 to +0.6 would solve this, but that uses up a much-too-small portion of the z-axis. I also know that the scale_colour_gradient2()
function can achieve what I want (it allows you to set the midpoint value), but that's a ggplot2()
function and I'm in lattice()
since ggplot2()
doesn't do 3-D surfaces like this (unless I missed something).
Here's what my plot looks like. It's crammed in the corner of the frame by design -- it's a 13x9 field that will be compared to a different plot containing a 24x16 field.