According to the documentation, "RegionFunction is an option for plotting functions that specifies the region to include in the plot drawn", and it can be used with ParametricPlot3D.

However, when using the latter command, one can also directly set variable plot limits, e.g., by writing {v, -f[u], f[u]} for some appropriate function f[u]. I am wondering whether there is any difference in doing this with respect to using RegionFunction.

For example, in the case below, the two plots produce exactly the same figure.

surface[u_, v_] := {Cos[v] Cos[u], Cos[v] Sin[u], Sin[v]}

f[u_] := u/2

ParametricPlot3D[surface[u, v], {u, 0, Pi}, {v, -f[u], f[u]}]

ParametricPlot3D[surface[u, v], {u, 0, Pi}, {v, -Pi/2, Pi/2}, 
 RegionFunction -> (-#4/2 < #5 < #4/2 &)]

enter image description here


Yes, there are some differences. For example, if we set f[u_]:=-u/2 and u in the interval {u,-Pi/2,Pi}, then the three pictures below are different.

surface[u_, v_] := {Cos[v] Cos[u], Cos[v] Sin[u], Sin[v]};
f[u_] := -u/2;
a = ParametricPlot3D[surface[u, v], {u, -Pi/2, Pi}, {v, -f[u], f[u]}, 
   PlotRange -> All];
b = ParametricPlot3D[surface[u, v], {u, -Pi/2, Pi}, {v, -10, 10}, 
   RegionFunction -> Function[{x, y, z, u, v}, -f[u] <= v <= f[u]], 
   PlotRange -> All];
c = ParametricPlot3D[surface[u, v], {u, -Pi/2, Pi}, {v, -10, 10}, 
   RegionFunction -> Function[{x, y, z, u, v}, -u/2 <= v <= u/2], 
   PlotRange -> All];
GraphicsRow[{a, b, c}]

enter image description here

  • $\begingroup$ Thanks for the answer. It is not empty if one writes RegionFunction -> (-#4/2 <= #5 <= #4/2 &) instead. Or, equivalently, RegionFunction -> Function[{x, y, z, u, v}, -u/2 <= v <= u/2]. $\endgroup$
    – MK7
    Jun 16 at 12:40
  • 1
    $\begingroup$ @MK7 Please see the updated. $\endgroup$
    – cvgmt
    Jun 16 at 13:08
  • $\begingroup$ I cannot make sense of plots a and c being different. Could you please provide some detail? $\endgroup$
    – MK7
    Jun 16 at 13:46
  • $\begingroup$ @MK7 It seems that ` {v, -f[u], f[u]}` means that v is between -f[u] and f[u], is difference from -f[u]<=v<=f[u] $\endgroup$
    – cvgmt
    Jun 16 at 13:49
  • $\begingroup$ OK I see it now. When u < 0, RegionFunction in your third ParametricPlot3D returns False. On the other hand, in the first ParametricPlot3D, replacing {v, -f[u], f[u]} with {v, f[u], -f[u]} does not affect the solution. $\endgroup$
    – MK7
    Jun 16 at 14:07

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.