I'm trying to create a volume plot in R that will show the smoothed density of points in 3D space. I'm using plotly to plot with scatter3D at the moment.
df = data.frame(a = sample(seq(.5,.8,.001),100),
b = sample(seq(0,.5,.001),100),
c = sample(seq(0,.3,.001),100),
value = sample(seq(0,1,.01),100))
plot_ly(df, x = ~a, y = ~b, z = ~c, type = 'scatter3d')
Setting type to 'mesh3d' works to connect these points as a surface in 3d space.
plot_ly(df, x = ~a, y = ~b, z = ~c, type = 'mesh3d')
However, trying to set the type to 'volume' gives me a blank plot each time.
plot_ly(df, x = ~a, y = ~b, z = ~c, value = ~value, type = 'volume',
isomin = 0, isomax = 1, opacity = 1)
The documentation is here: https://plotly.com/r/reference/volume/ and specifies:
Draws volume trace between iso-min and iso-max values with coordinates given by four 1-dimensional arrays containing the
value,x,yandzof every vertex of a uniform or non-uniform 3-D grid. Horizontal or vertical slices, caps as well as spaceframe between iso-min and iso-max values could also be drawn using this trace.
The python version of plotly provides an example: https://plotly.com/python/3d-volume-plots/ but I don't know where I'm missing the conversion to R. I've included the extra value dimension for volume plots, but it doesn't seem to do anything.


