I would like to plot a number of planes, each is an inequality. After I have plottet all the planes, I would like to have them combined, and color the area inside these lines. Image drawing a lot of 3d lines and coloring the area inside - this is what I am trying to do.
My data looks like this:
df <- structure(list(z = c(0, 0.06518, 0.08429, -0.01659, 0, 0.06808,
0.12383, -1, -0.01662, 0.28782, 0, -0.09539, 0.04255, 0.09539,
-0.13361, -0.28782, -0.14468, -0.19239, 0.10642), x = c(1, 0.02197,
0.03503, -0.02494, 0, 0.04138, 0.17992, 0, -0.02482, 0.1122,
0, 0.01511, 0.0011, -0.01511, -0.06699, -0.1122, -0.06876, 0.12078,
0.10201), y = c(0, 0.08735, 0.09927, 0.03876, -1, 0.22114, -0.00152,
0, 0.03811, -0.07335, 0, -0.03025, 0.07681, 0.03025, -0.23922,
0.07335, -0.25362, -0.09879, 0.05804), value = c(5801L, 135L,
162L, 109L, 4250L, 655L, 983L, 4500L, 108L, 1594L, 4400L, 540L,
147L, 323L, 899L, 1023L, 938L, 1627L, 327L)), .Names = c("z",
"x", "y", "value"), class = "data.frame", row.names = c(NA, -19L
))
Each row represents a equation of the form: z + x + y < value
. x
is the horizontale value, y
is the vertical and z
is the depth. z can be is solved to be: -x - y + value > z.
The limits of the coordinate system are:
x <- z <- seq(-6000, 6000, by = 1)
y <- seq(-4000, 4000, by = 1)
So, from each row I would like to draw a plane. Then I would like to combine all these planes, and fill out the values inside the lines. The result should look like a multi-side unequal dice. Or an ugly cut diamond.
I've been playing around with both the rgl
and persp
functions, but I am not sure where to even start. I am open to other software recommendations.
Leaning on one of the examples from persp3d
:
x <- seq(-6000, 6000, by = 1)
z <- x
y <- seq(-4000, 4000, by = 1)
f <- function(x, y) <- { r <- -x - y + value > z } # stuck here, can you handle an inequality here?
z <- outer(x, y, f)
open3d()
bg3d("white")
material3d(col = "black")
persp3d(x, y, z, col = "lightblue",
xlab = "X", ylab = "Y", zlab = "z")
I recognize it is quite large limits. If it helps to reduce them, feel free, or to increase the sequence(..., by = )
.