user101089 user101089 - 1 year ago 64
R Question

rgl materials to keep colors constant in a 3D plot

In the

package,, the function
is used to plot the planes corresponding to a system of linear equations in 3 variables of the form $A x = b$, using different colors for each plane.

However, there is something about the lighting used that makes the planes change color depending on the orientation of the plot which is confusing in this application, and I don't know how to change it.

Here is an example:


A <- matrix(scan(), byrow=TRUE, nrow=3)
2 -2 0
1 -1 1
4 4 -4

b <- 1:3

plotEqn3d(A, b)

To show the effect, I made a
, rotating about the Z axis.

movie3d(spin3d(rpm=15), duration=4, movie="plotEqn", dir=".")

It is clear enough in the movie which plane is which, but in a still image, it is not, depending on the orientation. What are the
or other settings I need to keep the color of the planes from changing?

enter image description here

A second question: The function uses
to set up the basic plot frame. Is it possible to turn off the tick marks and tick values on the axes? If so, how?

Answer Source

It seems better not to use plotEqn3d() but get paramaters and use rgl()'s function. You can remove geometoric effect by lit = F (detail; ?rgl.material).

plot3d(0,0,0, xlim = c(-2,2), ylim = c(-2,2), zlim = c(-3,3), type = "n", axes = F,
       xlab = "", ylab = "", zlab = "")      # a draft
planes3d(A[,1], A[,2], A[,3], -b, col = 2:(nrow(A) + 1), alpha = 1, lit = F)
spheres3d(solve(A, b), radius = 0.2)
 # axes3d(c("x", "y", "z"))  # fixed tick marks and values

play3d(spin3d(rpm=15), duration = 4)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download