Skip to content

customizing color key with plot3D

1 message · Waichler, Scott R

#
Karline,

Thank you for your help.  I discovered that in addition to including clim, I needed to omit breaks.  This code uses one of your other examples as a starting point and works as intended:

persp3D(z = volcano, zlim = c(-60, 200), phi = 20,
        colkey = list(length = 0.2, width = 0.4, shift = 0.15,
        cex.axis = 0.8, cex.clab = 0.85), lighting = TRUE, lphi = 90,
        clab = c("","height","m"), bty = "f", plot = FALSE)
elev.classes <- matrix(findInterval(volcano, vec = seq(50, 200, by=50)), nrow=nrow(volcano), ncol=ncol(volcano))
class.colors <- c("red", "blue", "green")
# add as image with own color key, at bottom
image3D(z = -60, colvar = elev.classes, add = TRUE,
        col = class.colors, #breaks = seq(0.5, 3.5, by=1),
        clim=c(1,3), 
        colkey = list(length = 0.2, width = 0.4, shift = -0.15,
                      cex.axis = 0.8, cex.clab = 0.85, addlines=TRUE, tick=FALSE, 
                      at = c(1.33, 2, 2.66), labels=paste("Class", 1:3)),
        clab = c("","Elev Classes"), plot = TRUE)

Your package plot3D is a huge help to me.  Previously I had to use a completely different software, VisIt, to do these kinds of composite plots.  R is my preferred tool and it is great to finally be able to do these at "home".

Thanks,
Scott Waichler
scott.waichler at pnnl.gov
Pacific Northwest National Laboratory
Richland, Washington, USA