1
$\begingroup$

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}]]
$\endgroup$
9
  • $\begingroup$ 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. $\endgroup$
    – Syed
    Jun 26 at 6:21
  • 1
    $\begingroup$ 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] $\endgroup$
    – Syed
    Jun 26 at 6:27
  • 1
    $\begingroup$ "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. $\endgroup$
    – xzczd
    Jun 26 at 6:29
  • 1
    $\begingroup$ "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. $\endgroup$
    – xzczd
    Jun 26 at 6:35
  • 1
    $\begingroup$ 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. $\endgroup$
    – Syed
    Jun 26 at 6:36

1 Answer 1

4
$\begingroup$
$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"}]

enter image description here

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – AtoZ
    Jun 26 at 7:08
  • 1
    $\begingroup$ @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? $\endgroup$
    – MarcoB
    Jun 26 at 14:32
  • 2
    $\begingroup$ 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). $\endgroup$
    – Bob Hanlon
    Jun 26 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.