How can I stop ListPlot3D from drawing segments between data points that differ by a certain threshold? In my example these far separated data points correspond to data samples either side of a discontinuity.

This question is a natural extension of the question here for ListPlot, and may well be a trivial extension for those who know what they're doing. Or perhaps not.

Here is an example:

r = x^2 + y^2;
data = Table[r Tan[r], {x, -2, 2, 0.01}, {y, -2, 2, 0.01}];
ListPlot3D[data, ClippingStyle -> None]

I appreciate that here we can split the plotting into two different regions before and after the discontinuity in Tan, but in the general case this is not so easy.

  • $\begingroup$ I tag @corey979, the accepted answerer from the previous question, but with no implied obligation! $\endgroup$
    – Tom
    Jan 17 '17 at 11:39

I suppose you could pick a plot range (perhaps from a test plot) and use RegionFunction to enforce it:

ListPlot3D[data, ClippingStyle -> None, 
 RegionFunction -> Function[{x, y, z}, -11 < z < 12]]

Mathematica graphics

  • $\begingroup$ I think this sort of tweaking of plots is for polishing presentations and papers, so using a test plot seems quite practical. However, a semi-automatic way to pick a range might be something like Quantile[Flatten@data, {0.05, 0.95}]. $\endgroup$
    – Michael E2
    Jan 17 '17 at 15:10

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.