1

Considering the following data

3.1 1   21.8
3.1 0.98    19.16666667
3.1 0.96    17.83333333
3.1 0.94    16.16666667
3.1 0.92    15.5
3.1 0.9 14.83333333
3.1 0.88    14.16666667
3.1 0.86    13.5
3.1 0.84    12.83333333
3.1 0.82    12.16666667
3.1 0.8 12.16666667
3.1 0.78    11.5
3.1 0.76    100
3.1 0.74    100

3.3 1   21.83333333
3.3 0.98    20.5
3.3 0.96    18.5
3.3 0.94    16.83333333
3.3 0.92    15.5
3.3 0.9 14.83333333
3.3 0.88    14.16666667
3.3 0.86    13.5
3.3 0.84    12.83333333
3.3 0.82    12.16666667
3.3 0.8 12.16666667
3.3 0.78    11.5
3.3 0.76    11.5
3.3 0.74    11.5

3.5 1   21.83333333
3.5 0.98    20.5
3.5 0.96    18.5
3.5 0.94    17.16666667
3.5 0.92    15.5
3.5 0.9 14.83333333
3.5 0.88    14.16666667
3.5 0.86    13.5
3.5 0.84    12.83333333
3.5 0.82    12.16666667
3.5 0.8 12.16666667
3.5 0.78    11.5
3.5 0.76    11.5
3.5 0.74    11.5

where the first column is x values, the second column is y values and the third column is z values.

How is it possible to plot a 3D surface while making a condition for hiding/removing the surface regions of z values equal to 100?

Stefan Pinnow
  • 29,535
Diaa
  • 9,599

1 Answers1

2

As Phelype already linked in the comment below the question, key is to add the option unbounded coords=jump. Then the only thing remaining is to transfer the 100 to NaN. For details please have a look at the comments in the code.

% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
%        view={0}{90},
        % you need to add this to get the desired result
        unbounded coords=jump,
    ]
        \addplot3 [
            surf,
        ] table [
            x=x,
            y=y,
            % use an expression to state that z values of 100 should be ignored
            z expr={\thisrow{z} == 100 ? NaN : \thisrow{z}},
        ] {
            x   y       z
            3.1 1.00    21.8
            3.1 0.98    19.16666667
            3.1 0.96    17.83333333
            3.1 0.94    16.16666667
            3.1 0.92    15.5
            3.1 0.90    14.83333333
            3.1 0.88    14.16666667
            3.1 0.86    13.5
            3.1 0.84    12.83333333
            3.1 0.82    12.16666667
            3.1 0.80    12.16666667
            3.1 0.78    11.5
            3.1 0.76    100
            3.1 0.74    100

            3.3 1       21.83333333
            3.3 0.98    20.5
            3.3 0.96    18.5
            3.3 0.94    16.83333333
            3.3 0.92    15.5
            3.3 0.9     14.83333333
            3.3 0.88    14.16666667
            3.3 0.86    13.5
            3.3 0.84    12.83333333
            3.3 0.82    12.16666667
            3.3 0.8     12.16666667
            3.3 0.78    11.5
            3.3 0.76    11.5
            3.3 0.74    11.5

            3.5 1       21.83333333
            3.5 0.98    20.5
            3.5 0.96    18.5
            3.5 0.94    17.16666667
            3.5 0.92    15.5
            3.5 0.9     14.83333333
            3.5 0.88    14.16666667
            3.5 0.86    13.5
            3.5 0.84    12.83333333
            3.5 0.82    12.16666667
            3.5 0.8     12.16666667
            3.5 0.78    11.5
            3.5 0.76    11.5
            3.5 0.74    11.5
        };
    \end{axis}
\end{tikzpicture}
\end{document}

image showing the result of above code

Stefan Pinnow
  • 29,535