3
$\begingroup$

I have a weird problem with DensityPlot, ContourPlot, and Plot3D.

The function I want to plot is elementary:

DensityPlot[((-1 + 8 F^2 - 4 F Sqrt[-1 + 4 F^2]) R)/(8 F^2), {R, F} \[Element] Rectangle[{100, 1}, {1000, 5}]]

However, the result is a very jagged one. Same for ContourPlot, and Plot3D.

The way to get smooth plots is to specify the plot region not with Rectangle but with the standard way, like {R, 100, 1000}, {F, 1, 5}.

DensityPlot[((-1 + 8 F^2 - 4 F Sqrt[-1 + 4 F^2]) R)/(8 F^2), {R, 100, 1000}, {F, 1, 5}]

This gives a smooth plot.

What's happening actually under the hood?

Is there any workaround for the problem when you don't have any other way to represent the plot region other than using some region objects, like Rectangle, Disk, Annulus, etc?


Mathematica 13.2.1.0 on Windows11 (64bit)

$\endgroup$

2 Answers 2

2
$\begingroup$

A usual way to improve a plot by PlotPoints and WorkingPrecision works, though the execution is slow.

DensityPlot[((-1 + 8 F^2 - 4 F Sqrt[-1 + 4 F^2]) R)/(8 F^2), {R, F} \[Element] 
Rectangle[{100, 1}, {1000, 5}],WorkingPrecision -> 20, PlotPoints -> 300]

enter image description here

The result of

DensityPlot[((-1 + 8 F^2 - 4 F Sqrt[-1 + 4 F^2]) R)/(8 F^2), {R,   F} \[Element] 
 RegionConvert[Rectangle[{100, 1}, {1000, 5}], "Parametric"],  PlotPoints -> 200, WorkingPrecision -> 20]

is not better.

$\endgroup$
2
  • 1
    $\begingroup$ The quality of DensityPlot[((-1 + 8 F^2 - 4 F Sqrt[-1 + 4 F^2]) R)/(8 F^2), {R, F} \[Element] Annulus[{100, 6}, {1, 5}]] also leaves much to be desired. $\endgroup$
    – user64494
    Jun 28 at 16:05
  • $\begingroup$ Far better than the case of Rectangle, but still slightly jagged in the Small F region and weird. I suspect these results stem from some internal procedure about How mathematical plots functions within a given area. Maybe depending on where the first PlotPoints are set on the plot region. I don't know... $\endgroup$ Jun 30 at 1:42
-2
$\begingroup$

The main problem seems to be the distorted Rectangle!

Try

DensityPlot[((-1 + 8 F^2 - 4 F Sqrt[-1 + 4 F^2]) R)/(8 F^2), {R, 100,1000}, {F, 1, 5}, PlotPoints -> 100]

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ Did you read "The way to get smooth plots is to specify the plot region not with Rectangle but with the standard way, like {R, 100, 1000}, {F, 1, 5}" and "Is there any workaround for the problem when you don't have any other way to represent the plot region other than using some region objects, like Rectangle, Disk, Annulus, etc?" in the question before having posted it? Can you ground your "The main problem seems to be the distorted Rectangle!"? $\endgroup$
    – user64494
    Jun 28 at 10:45
  • 2
    $\begingroup$ The result of DensityPlot[((-1 + 8 F^2 - 4 F Sqrt[-1 + 4 F^2]) R)/(8 F^2), {R, F} \[Element] Rectangle[{1, 1}, {10, 5}]] is also bad (compare with DensityPlot[((-1 + 8 F^2 - 4 F Sqrt[-1 + 4 F^2]) R)/(8 F^2), {R, 1, 10}, {F, 1, 5}]) so your speculation does not correspond to reality. $\endgroup$
    – user64494
    Jun 28 at 10:52
  • 1
    $\begingroup$ Obviously I didn't read the whole question, but my answer seems to be quite smooth. Otherwise, I refrain from further hopeless discussions $\endgroup$ Jun 28 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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