# How can one eliminate moiré artifacts from ListDensityPlot3D?

I’m having a hard time eliminating some moiré-like artifacts from the 3D output of ListDensityPlot3D.

Here is an example:

n = 1.5;
ρCore = 166;
bdElectronDensityConversion = 5.25*^23*ρCore;
ξCore = \$MachineEpsilon;
R = 8.26*^9*Quantity["cm"];
M = 0.04*Quantity["SolarMass"];
K = (M^(1/3)*R*Quantity["GravitationalConstant"])/2.3573;
a = Sqrt[((n + 1)*(K*(ρCore*Quantity["g/cc"])^((1 - n)/n)))
/(4*Pi*Quantity["GravitationalConstant"])];
/QuantityMagnitude[UnitConvert[a]]);
system = {Dt[ξ^2*Derivative[1][θ][ξ], {ξ}]/ξ^2 == -θ[ξ]^n,
θ[ξCore] == 1,
Derivative[1][θ][ξCore] == 0};
sol = NDSolve[system, θ, {ξ, ξCore, ξRadius}][[1]];

Rkm = QuantityMagnitude@UnitConvert[R, "km"];
Show[DensityPlot3D[
{x, y, z} ∈ RegionDifference[
Ball[{0, 0, 0}, Rkm], Cuboid[{0, -Rkm, 0}, {Rkm, Rkm, Rkm}]],
PerformanceGoal -> "Quality", PlotPoints -> 100,
OpacityFunction -> None,
ColorFunction -> ColorData[{"SolarColors", {1*^25, 8*^25}}],
ColorFunctionScaling -> False], ImageSize -> Large]


When I run this code, I see this:

Sadly, moiré artifacts run throughout the cutaway faces of the ball, giving the false impression that a non-spherically-symmetric structure exists in the solution. This could mislead anyone hoping to interpret the plot!

I’d greatly appreciate any advice on eliminating these artifacts. I’ve tried increasing PlotPoints, to no avail.

Thanks!

• How long does the graphic take to generate on your machine? (my question isn't related to the answer of your question, but I just let it run for a few minutes with no success... if it takes minutes to test each thing it might make the problem difficult to troubleshoot!) – user6014 Nov 30 '18 at 4:32
• Do you really need to use ListDensityPlot if you're only going to show a cutaway? You can speed this plot by orders of magnitude by just plotting on the sphere surface and cutting planes. – David G. Stork Nov 30 '18 at 6:23
• @user6014: I’ve reduced PlotPoints to 100 in the example, since this still exhibits the moiré artifacts. It takes about 1 min 40 s to run on my machine. – Daine Nov 30 '18 at 19:35
• @DavidG.Stork: That would help for this example, but sadly the full code includes a ListDensityPlot3D displaying data, which exhibits the same moiré artifacts. If you know of a comparable workaround for that case, however, it could be very helpful indeed. – Daine Nov 30 '18 at 19:43
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Dec 16 '18 at 20:41

Maybe this?:

MapAt[
Rotate[#, -2 Pi/3, {1, 1, 1}] &@Scale[#, {1, -1, 1}] &,
SliceDensityPlot3D[(bdElectronDensityConversion*θ[
Rkm)^2 + (z*ξRadius/Rkm)^2]]^n /. x -> -x /. sol) //
Evaluate, {"CenterCutSphere"}
, {z, -Rkm, Rkm}, {x, -Rkm, Rkm}, {y, -Rkm, Rkm},
ColorFunction -> ColorData[{"SolarColors", {1*^25, 8*^25}}],
ColorFunctionScaling -> False, AxesLabel -> RotateLeft@{z, x, y}
],
1]


Unfortunately, "CenterCutSphere" is a cut with respect to the azimuthal angle only, so conjugation by some geometric transformations is necessary.