-----Original Message-----
From: Karline Soetaert [mailto:Karline.Soetaert at nioz.nl]
Sent: Wednesday, June 21, 2017 4:16 AM
To: Waichler, Scott R
Subject: RE: customizing color key with plot3D
There is an example in the colkey help file:
example(colkey)
will show it ( working on the iris dataset)
I think the basic thing is that you can use "at" to position the labels but then
you also have to specify clim , i.e. "at = c(1.33, 2, 2.66), clim = c(0.5,3.5), col =
jetc.col(3)...."
Here is the example:
with(iris, scatter3D(x = Sepal.Length, y = Sepal.Width,
z = Petal.Length, colvar = as.integer(Species),
col = c("orange", "green", "lightblue"), pch = 16, cex = 2,
clim = c(1, 3), ticktype = "detailed", phi = 20,
xlab = "Sepal Length", ylab = "Sepal Width",
zlab = "Petal Length", main = "iris",
colkey = list(at = c(1.33, 2, 2.66), side = 1,
addlines = TRUE, length = 0.5, width = 0.5,
labels = c("setosa", "versicolor", "virginica") )))
hope it helps,
Karline
-----Original Message-----
From: Waichler, Scott R [mailto:Scott.Waichler at pnnl.gov]
Sent: woensdag 21 juni 2017 2:01
To: R. Help <r-help at r-project.org>
Cc: Karline Soetaert <Karline.Soetaert at nioz.nl>
Subject: customizing color key with plot3D
Hi, I am doing composite plots with the package plot3D. One of my
variables is qualitative and indexed to integers, and I would like the legend
for it to have labels located at the integer values (midpoints), and not at the
breaks between classes. In the example below, the Elev Classes legend has
labels at the breaks and nothing at the midpoints. How can I show the class
labels at 1:3, and not the breaks?
library(plot3D)
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) # classify the volcano
elevations with 3 classes 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),
colkey = list(length = 0.2, width = 0.4, shift = -0.15,
cex.axis = 0.8, cex.clab = 0.85, addlines=TRUE, tick=FALSE,
at = 1:3, labels=paste("Class", 1:3)),
clab = c("","Elev Classes"), plot = TRUE)
Thanks,
Scott
Scott Waichler
Pacific Northwest National Laboratory
Richland, Washington, USA
scott.waichler at pnnl.gov