I'm trying to make images like this:
to illustrate 2D integrals to a calculus class.
I used the code
f1[x_,y_]=x^2+x y;
region1 = (x - 1.5)^2 + (y - 1.5)^2 < 1 && y > 1.5;
fig1 = Plot3D[f1[x, y], {x, 0, 3}, {y, 0, 3}, Mesh -> None,
PlotStyle -> Opacity[0.25]];
fig2 = Plot3D[f1[x, y], {x, 0, 3}, {y, 0, 3},
RegionFunction -> Function[{x, y, z}, region1], Filling -> Axis,
Mesh -> None, PlotStyle -> {Opacity[.25]},
FillingStyle -> {Gray, Opacity[.5]}];
Show[fig1, fig2]
to make this but would like to automate the procedure, defining a new plot function that takes as input the integration region used by RegionPlot:
IntRegionPlot[f_, region_] :=
Module[{background, volume},
background =
Plot3D[f[x, y], {x, 0, 3}, {y, 0, 3}, PlotRange -> {0, Automatic},
Mesh -> None, PlotStyle -> Opacity[.25], BoxRatios -> {1, 1, 1}];
volume :=
Plot3D[f[x, y], {x, 0, 3}, {y, 0, 3},
RegionFunction -> Function[{x, y, z}, region], Filling -> Bottom,
Mesh -> None, PlotStyle -> Opacity[.25],
FillingStyle -> {Gray, Opacity[.5]}];
Show[background, volume]];
IntRegionPlot[f1, region1]
But this yields the error
Plot3D::invregion: "(-1+x)^2+(-1+y)^2<1 must be a Boolean function."
What have I done wrong with RegionPlot?