Message Boards Message Boards

0
|
4981 Views
|
6 Replies
|
8 Total Likes
View groups...
Share
Share this post:

How to Avoid Plotting when output axis = 0 with Plot3D[]?

Posted 9 years ago
Attachments:
POSTED BY: Greg
6 Replies
Posted 9 years ago
Attachments:
POSTED BY: Greg

So this won't work unless you have a large region that's actually just 0. If Plot3D doesn't evaluate Sin[x + y^2] /. {0 -> Indeterminate} at a point that produces exactly 0 them it won't work.

So you'll see it work here:

Show[Plot3D[
  If[Last[Flatten[NSolve[p == x*Log[t + 1], x, Reals]]][[2]] > 6, 1, 
    If[Last[Flatten[
         NSolve[p == x*Log[t + 1], x, Reals]]][[2]] < -0.25, 0, 
     Last[Flatten[
        NSolve[p == x*Log[t + 1], x, Reals]]][[2]]]] /. {0 -> 
     Infinity}, {t, 0, 5.4}, {p, -1, 1}, PlotStyle -> Opacity[0.35], 
  FaceGrids -> All, PerformanceGoal -> "Quality", 
  ColorFunction -> "Rainbow", PlotLegends -> Automatic, 
  PlotTheme -> "Web", ImageSize -> 700, BoundaryStyle -> Thick, 
  AxesLabel -> Automatic, RegionFunction -> Function[{z}, 0 <= z]], 
 PlotRange -> {{0, 5.4}, {-1, 1}, {-1, 1}}]

But... I mean maybe it'd be easier to use an If Statement instead of Replace (/.)

Plot3D[Sin[x + y^2] /. {num_ /; Abs[num] < 0.1 -> Indeterminate}, {x, -3,  3}, {y, -2, 2}]
POSTED BY: Sean Clarke
POSTED BY: Sean Clarke
Posted 9 years ago
Attachments:
POSTED BY: Greg

I tried a couple of things with RegionFunction. Using z!=0 doesn't work. It knows that's an infinitely thin region. Something with some thickness however will work:

RegionFunction -> Function[{x, y, z}, z > 0.01 || z < -0.01]

I think a simpler solution to the problem is to make the function being plotted just not exist in the plotting range when it actually equals zero. Basically you just have the function being plotted return Infinity or Indeterminate instead of 0:

Plot3D[function /. {0 -> Indeterminate}, {t, 0, 5.4}, {p, -1, 1}, ...]
POSTED BY: Sean Clarke
Posted 9 years ago
POSTED BY: Greg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract