I'm trying to make a density plot of some data on a solid sphere, but I couldn't get ListDensityPlot3D
to plot anything. I think there's something I'm missing, as I can't even get a simple plot to work with this function.
data = Flatten[Table[{r Sin[θ] Cos[ϕ], r Sin[θ] Sin[ϕ], r Cos[θ], Cos[θ]},
{r, 0, 1, 0.1}, {θ, 0, π, π/10}, {ϕ, 0, 2 π, 2 π/20}], 2];
cleandata = DeleteDuplicates[data];
Dimensions[cleandata]
ListPointPlot3D[cleandata[[;; , {1, 2, 3}]], BoxRatios -> {1, 1, 1}]
ListDensityPlot3D[cleandata]
The first command creates a list of {x,y,z,f}
points. The second removes the duplicate points along the z axis. The third just shows the dimensions, demonstrating that they're correct. The fourth shows the locations of the points in 3D space. I expect the fifth to give me the density plot, but instead it shows nothing. This is the subject of my confusion.
What am I missing?
Edit: Fixed code to remove duplicates on z axis.
{0, 0, 0, f}
. Your list has a ton of duplicated points, and I don't think Mathematica will plot properly with a bunch of duplicates. $\endgroup$ListDensityPlot3D[RandomSample[data,250]]
works. $\endgroup$