Display common color scale on multiple scatter3D plots

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Display common color scale on multiple scatter3D plots

Luigi
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

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Display common color scale on multiple scatter3D plots

Jim Lemon-4
Hi Luigi,
Upon careful reading of the help page, you can do it with scatter3D:

scatter3D(X, Y, Z, col.var = Z, pch = 16, cex = 2,clim=c(0.5,3))
scatter3D(X, Y, K, col.var = K, pch = 16, cex = 2,clim=c(0.5,3))

Jim

On Thu, Mar 14, 2019 at 9:32 PM Luigi Marongiu <[hidden email]> wrote:

>
> 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
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Display common color scale on multiple scatter3D plots

Luigi
Thank you!
I even bought a manual on this and such feature was not there. Case solved.
Regards,
Luigi

On Thu, Mar 14, 2019 at 11:36 PM Jim Lemon <[hidden email]> wrote:

>
> Hi Luigi,
> Upon careful reading of the help page, you can do it with scatter3D:
>
> scatter3D(X, Y, Z, col.var = Z, pch = 16, cex = 2,clim=c(0.5,3))
> scatter3D(X, Y, K, col.var = K, pch = 16, cex = 2,clim=c(0.5,3))
>
> Jim
>
> On Thu, Mar 14, 2019 at 9:32 PM Luigi Marongiu <[hidden email]> wrote:
> >
> > 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
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.



--
Best regards,
Luigi

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.