0
$\begingroup$

Before updating Mathematica license to version 12, I was able to exclude regions of plots (in Plot, Plot3D, DensityPlot) with RegionFunction without needing the condition to explicitly display its dependence to the variables. Now I get the following error message: "Function [...] must be a Boolean function".

As an example, I plot the following exponential function:
Plot[Exp[x], {x, 0, 1}, PlotRange -> {{0, 1}, {0, 3}}]

enter image description here

I want to exclude points according to a function of x that is different from Exp[x], for example x^2:

enter image description here

I used to write it:

functest = x^2;
Plot[Exp[x], {x, 0, 1}, PlotRange -> {{0, 1}, {0, 3}}, RegionFunction -> Function[{x, y}, functest < 0.5]]

But if I do so now, I get the error message and it does not exclude any points.

It works if I define the function functest with its argument:

functest[x_] := x^2;
Plot[Exp[x], {x, 0, 1}, PlotRange -> {{0, 1}, {0, 3}}, RegionFunction -> Function[{x, y}, functest[x] < 0.5]]

My problem is that functest in my code is typically a long analytical expression (for example the solutions of a system of differential equations) and I would like to find a way to call it without having to define it explicitly with respect to its variables.

$\endgroup$
  • 3
    $\begingroup$ Looks like an evaluation leak that was fixed. Use Function[{x, y}, Evaluate[functest < .5]] instead. $\endgroup$ – Carl Woll Jun 3 at 19:24
  • $\begingroup$ Awesome it works! $\endgroup$ – Elsa Jun 3 at 20:52

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.