I have a dataframe of coordinates (x,y,z)
where a function takes value 1, with all other coordinates being set to 0. Here is a simplified sample dataset analogous to what I am working with:
dd <- data.frame(x = c(rep(1,9),rep(2,9),rep(3,9)),
y=rep(c(rep(1,3),rep(2,3),rep(3,3)),3),
z= rep(c(1,2,3),3^2),
t = rep(1,3^3))
As can be seen from the following scatter plot, these points define a cube:
plot_ly(df, x = ~dd$x, y=~dd$y,z=~dd$z,
type = 'scatter3d',
mode = 'markers')
I would like to plot the surfaces enclosing this cube but I can't figure out how to do it (note that in my data the shape is more complex and there is no explicit function defining z as a function of x and y but still define a polyhedron). I tried using plot_ly
with various options, surface3d
(including solution given at R: Plotting a 3D surface from x, y, z, and many other options suggested at StackOverflow but I can't get the full cube plotted. Any suggestion will be greatly appreciated.