8
$\begingroup$

I was trying to devise an answer to this question that relied entirely on MeshFunctions to do all the work, but I ran into some unexpected behavior.

Consider two simple MeshFunctions and how they behave separately:

func1 = If[#1 > 0, #1 + #2] &;
func2 = If[#2 < 0, #1] &;
RegionPlot[x^2 + y^2 < 3, {x, -2, 2}, {y, -2, 2},
   MeshFunctions -> {#},
   Mesh -> {Range[-1, 4, .5]},
   PlotPoints -> 100] & /@ {func1, func2}

Mathematica graphics

My understanding is that I should be able to add both of these functions together, perhaps with different styles via

RegionPlot[x^2 + y^2 < 3, {x, -2, 2}, {y, -2, 2},
 MeshFunctions -> {func1, func2},
 Mesh -> {Range[-1, 4, .5], Range[-1, 4, .5]},
 MeshStyle -> {{Red}, {Blue}},
 PlotPoints -> 100]

Mathematica graphics

But it didn't work; the conditional statement from func1 is used when applying func2. If I remove the If statements, using MeshFunctions -> {#1 + #2 &, #1 &} then it works just fine.

Is this in the documentation somewhere?

$\endgroup$
  • $\begingroup$ Perhaps "The Subscript[m, i] should normally be chosen to be continuous monotonic functions." ("Details", docs for MeshFunctions) But it's a bit vague about what happens when you use functions that are undefined (or return Null) over part of the plot domain. $\endgroup$ – Michael E2 Sep 1 '16 at 2:07
  • $\begingroup$ @MichaelE2 That sounds about right, probably it $\endgroup$ – Jason B. Sep 1 '16 at 11:17

Your Answer

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

Browse other questions tagged or ask your own question.