I'm running into problems with a weird edges to my Plot3D with a Disc domain. MWE:

Plot3D[(x^2 + y^2 - 100)^2, {x, y} \[Element] Disk[{0, 0}, 13.5], PlotPoints -> 100]

which produces

enter image description here

I don't know where the scalloping is coming from. It disappears for low PlotPoints, e.g. 10, but I need high plotpoints for the colour scheme I'm using. I've tried using Show[] with a slightly lower PlotRange to try to clip them off, but they remain.

I would dearly love a version with a crisp straight edge for my paper - would be grateful for any fixes!


2 Answers 2

Plot3D[(x^2 + y^2 - 100)^2, {x, -14, 14}, {y, -14, 14}, 
 PlotPoints -> 100, 
 RegionFunction -> 
  Function[{x, y}, {x, y} ∈ Disk[{0, 0}, 13.5]]]

enter image description here


rm = RegionMember[Disk[{0, 0}, 13.5]]; 
Plot3D[(x^2 + y^2 - 100)^2, {x, -14, 
  14}, {y, -14, 14}, PlotPoints -> 100, 
 RegionFunction -> Function[{x, y}, rm@{x, y}]]
  1. Rather than manually increasing the number of PlotPoints, increase the MaxRecursion parameter instead, to let the built-in plotting machinery decide where to use extra points (e.g. in areas of high curvature). This can often be much more efficient. The value of MaxRecursion -> 4 shown below was found by trial and error, starting low and increasing it until a satisfactory result was achieved.

  2. As @cvgmt showed in their answer as well, use a pre-calculated RegionMemberFunction obtained from RegionMember as your RegionFunction in Plot3D.

This results in the following code:

rmf = RegionMember[Disk[{0, 0}, 13.5]];

  (x^2 + y^2 - 100)^2, {x, -14, 14}, {y, -14, 14},
  RegionFunction -> (rmf[{#1, #2}] &),
  MaxRecursion -> 4

desired 3D plot with no scalloped edges

This approach is quite a bit faster than the alternative with explicit PlotPoints: on my computer this version takes roughly 0.5 s, whereas the equivalent approach with PlotPoints -> 100 takes roughly 1.5 s.


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.