R: plot a plane in 3D



I am trying to add the z=0 plane to a 3D plot. The code I use is

zero = matrix(0, 20, 20)
persp3D(x=seq(1,20), y=seq(1,20), z = Delta_B, theta = 20, xlab = "D", ylab = "IR", zlab = "B increment")
persp3D(x=seq(1,20), y=seq(1,20), z = zero, col = "black", add = T)

But the z=0 plane does not appear.enter image description here

If I jitter the plane with

zero = jitter(matrix(0, 20, 20))

Then I can see it properly.

enter image description here

In fact trying to plot the plane alone produces and empty graph.

persp3D(x=seq(1,20), y=seq(1,20), z = zero, col = "black")

enter image description here


A partial solution would be to use

zero = jitter(matrix(0, 20, 20)) / 10000

which results in a plane that is indistinguishable from the intended one.

enter image description here

Continue reading...