In this answer I was trying to make a 3D stack of disk-shaped density plots, so I was using ListSliceDensityPlot3D
. I resorted to using a set of nonrectangular grid points that were drawn from a unit circle, and the corresponding DensityPlot
was circular. Something like this,
ListSliceDensityPlot3D[
Flatten[
Table[
{#1, #2, z, Sin[(#1 - #2) z]} & @@@ RandomPoint[Disk[], 1000],
{z, 1, 11, 2}],
1],
{"ZStackedPlanes", Range[1, 11, 2]}
]
But this seems a bit klunky, and only results in nice disk-shaped slices as the number of random points gets larger.
What I'd like to do is take advantage of the ability to specify your own surfaces as the second argument to SliceDensityPlot3D
or its list variant, rather than using "ZStackedPlanes".
I know that any 3D region can be used as a surface, so I want to create a disk-shaped surface. There isn't a built-in Disk3D
function, but Taiki made such a function here.
disk3D[]
creates a Polygon
out of a set of
{ListPointPlot3D @@ #, Graphics3D@#} &@disk3D[]
Here are the results when I try to use these Polygon
objects as surfaceregions, compared to the built-in stacked planes:
SliceDensityPlot3D[
Sin[(x - y) z], #, {x, -1, 1}, {y, -1, 1}, {z, 0, 12},
PlotPoints -> 50] & /@ {disk3D[{0, 0, #}] & /@
Range[1, 11, 2], {"ZStackedPlanes", Range[1, 11, 2]}}
We see a clear distortion of the function, and the resulting plot has little to no connection with the underlying density. I also receive repeated RegionIntersection::reg
and RegionBounds::reg
warnings. I can make these warnings go away by discretizing the regions before feeding them to SliceDensityPlot3D
, but that only brings the problem into sharper relief:
SliceDensityPlot3D[Sin[(x - y) z],
DiscretizeGraphics[disk3D[{0, 0, #}]] & /@ Range[1, 11, 2], {x, -1,
1}, {y, -1, 1}, {z, 0, 12}]
The density plots seem to be sampled preferentially along the mesh lines created when discretizing the graphics:
DiscretizeGraphics[disk3D[{0, 0, 0}]]
This seems to clearly be a bug in SliceDensityPlot3D
- one that is just as bad in SliceContourPlot3D
. Increasing the number of PlotPoints
does not have an effect.
How can I turn the disk3D
object into a surface in a better way? Is there any way to ensure that the discretized graphics has a better mesh function?
For the record, it is possible to get the plot by the circuitous route of first creating a ListContourPlot3D
object for each disk, discretizing that to create a surface region (again using Quiet
because of the errors) - thanks to Szabolcs. Using this code (omitted here for brevity), we can see that it is necessary to get a very fine mesh to get a decent plot:
But that code is very slow, and I'd like to be able to use the Polygon
objects instead.