# An issue in ListDensityPlot

I am having an issue with getting a nice plot but ListDensityPlot is returning a plot with white area. I thought this could be due to the singularity, then I have also tried by manually removing the ComlexInfinity from the corresponding list, but the problem remains the same. PlotRange --> All doesnt seem to help either.

    x1 = 2;
y1 = 2.45; a = 1;h = 1;l = 5;A = 0.5;alpha = 4;s = ArcTan[y1/x1]

ListDensityPlot[Table[((((a^2*(l*h - alpha) +
s) - (a^2*x2 - a^2*y2 - 2*a*x2^2 - 2*a*y2^2)*
A)/((x2^2 + y2^2)*(a^2 + (x1^2 + y1^2 + x2^2 + y2^2))))^2/4), {x2, -2, 2, 0.1}, {y2, -2, 2, 0.1}]]

• DensityPlot[((((a^2*(l*h - alpha) + s) - (a^2*x2 - a^2*y2 - 2*a*x2^2 - 2*a*y2^2)* A)/((x2^2 + y2^2)*(a^2 + (x1^2 + y1^2 + x2^2 + y2^2))))^2/ 4), {x2, -2, 2}, {y2, -2, 2}, PlotPoints -> 100, MaxRecursion -> 2, PlotLegends -> Automatic]. You can also change DensityPlot to ContourPlot to see contours.
– Syed
Jun 26 at 6:21
• DensityPlot[ Clip[((((a^2*(l*h - alpha) + s) - (a^2*x2 - a^2*y2 - 2*a*x2^2 - 2*a*y2^2)* A)/((x2^2 + y2^2)*(a^2 + (x1^2 + y1^2 + x2^2 + y2^2))))^2/ 4), {0.001, 0.05}], {x2, -2, 2}, {y2, -2, 2}, PlotPoints -> 100, MaxRecursion -> 2, PlotLegends -> Automatic]
– Syed
Jun 26 at 6:27
• "the x and y labelling should be -2 to +2?" You need to tell ListDensityPlot it's from -2 to 2 with DataRange. Currently this info is missing. Jun 26 at 6:29
• "I have also tried by manually removing the ComlexInfinity from the corresponding list, but the problem remains the same. " How did you try? With (*your data*) /. ComplexInfinity -> 10000 and PlotRange -> All, the white area goes away. Jun 26 at 6:35
• there's still **some** issue with it is not a scientific description. Mathematica does an accurate plot. If you don't like the color scheme, you an fake it with Clip etc.
– Syed
Jun 26 at 6:36

\$Version

(* "13.0.1 for Mac OS X x86 (64-bit) (January 28, 2022)" *)

Clear["Global*"]

x1 = 2; y1 = 245/100; a = 1; h = 1; l = 5;
A = 1/2; alpha = 4; s = ArcTan[y1/x1];

expr = ((((a^2*(l*h - alpha) + s) -
(a^2*x2 - a^2*y2 - 2*a*x2^2 - 2*a*y2^2)*A)/
((x2^2 + y2^2)*(a^2 + (x1^2 + y1^2 + x2^2 + y2^2))))^2/4);


As the PlotRange is increased, the white area decreases

Manipulate[
Column[
{Plot3D[expr, {x2, -2, 2}, {y2, -2, 2},
PlotPoints -> 100,
MaxRecursion -> 3,
PlotRange -> {0, max},
ClippingStyle -> None],
DensityPlot[expr, {x2, -2, 2}, {y2, -2, 2},
PlotPoints -> 100,
MaxRecursion -> 3,
PlotLegends -> Automatic,
PlotRange -> {0, max}]}],
{{max, 1}, 0.25, 100, 0.25, Appearance -> "Labeled"}]


• Thanks a lot. The white area is however still there? Isn't there a way to circumvent it altogether? With increasing PlotRange the plot disappears entirely, i.e., PlotRange-->All leaves nothing to see in the plot.
– AtoZ
Jun 26 at 7:08
• @AtoZ I don't understand what your desired result would be. You see the shape of the 3D shape of your plot: what should happen in the density plot where the values go way up? Do you want a logarithmic representation of the density perhaps? Jun 26 at 14:32
• The center of the plot is unbounded and is clipped. The white area is the part of the plot that is clipped. You can use ClippingStyle -> color` to change the white area to another color; however, that color will still represent that the region is clipped (unknown values). Jun 26 at 14:36