[R] Display common color scale on multiple scatter3D plots

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Thu Mar 14 11:31:40 CET 2019


Dear all,
I am trying to display multivariate data using the library plot3D. I
have 3 variables that go on the axis and a fourth that I would like to
display as a color shade. However, the scale differs between plots
because the data I am using varies.
Would be possible to maintain a single scale so that the different
points will have the same shade on different plots? This would be like
giving the same axis scale on different plots.

For example, I got the following:
>>>>
set.seed(50)
x = runif(10, 6, 18)
y = runif(10,  5,  7)
z = runif(10, 0.7, 3.14)
k = runif(10, 0.5, 1.2)
w = runif(10, min(z, k), max(z,k))
df = my.data <- data.frame(x, y, z, k, w)

library("plot3D")
X = df$x
Y = df$y
Z = df$z
K = df$k
W = df$w
scatter3D(X, Y, Z, col.var = Z, pch = 16, cex = 2)
scatter3D(X, Y, K, col.var = K, pch = 16, cex = 2)
<<<

In these plots the scale varies (0.6-0.9 in the first plot, 1.5-2.5 in
the second); I tried by creating a common scale with the variable W
which ranges from the min and max of the fourth levels represented by
the variables Z and K, but the result is the same:
scatter3D(X, Y, Z, col.var = W, pch = 16, cex = 2)
scatter3D(X, Y, K, col.var = W, pch = 16, cex = 2)

Essentially, I would like the variables Z and K to be shaded according
to a common scale so that I could evaluate the shades of the two plots
directly.
Would that be possible?
Thank you.

-- 
Best regards,
Luigi



More information about the R-help mailing list