2

Suppose I would like to draw some surface plot of function which includes singularities and therefore values in infinity (for example 1/(x²+y²)). This topic was already discussed on TeX SE (see). Here is MWE:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[grid=both,restrict z to domain*=0:10]
    \addplot3 [surf,samples=71,
        domain=-2:2,miter limit=1] {1 / (x^2 + y^2)};
  \end{axis}
\end{tikzpicture}
\end{document}

Now, if I already have good looking shape near singularities (increased number of samples to 71):

enter image description here

on top of these points, there is a plane which I would like to remove and make it looks hollow (like on the picture bellow)

enter image description here

Since I didn't find any answer to this, I was thinking about using if in this manner:

IF (function value != value of mentioned plane)
    addplot(function)

Hint: I tried IF THEN from tikz math library, but I ended in errors. But this can work I guess.

Q: Is possible to make similar code in LaTeX?

Is there more simple way to remove top plane?

Edit According to cfr suggestions, I did some corrections and MWE is provided.

4
  • It is better to include an example here, even if it is duplicating the one linked (of course with an attribution and link to the original) so that your question remains meaningful even if the linked one changes or gets deleted.
    – cfr
    Sep 10 '17 at 12:28
  • tex.stackexchange.com/questions/333552/… You want this but with a hole instead of a cap? But wouldn't the inside surfaces, so to speak, show in the hole, so the hole won't be seen, even if you don't have the cap?
    – cfr
    Sep 10 '17 at 12:30
  • Ok, I did some corrections and illustrative images are included. Hope it is clear now
    – struct
    Sep 10 '17 at 12:50
  • That's much clearer now, thanks. I don't know the answer - but at least I understand the question :).
    – cfr
    Sep 10 '17 at 13:03
2

The color data which is used to choose the segment color can be used to hide individual segments. To this end, you have to assign an unbounded color data (like "not a number"):

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[grid=both,restrict z to domain*=0:10]
    \addplot3 [surf,samples=71,
        domain=-2:2,miter limit=1,
        point meta={sqrt(x^2+y^2)<0.23 ? nan : z},
    ] {1 / (x^2 + y^2)};
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

The value point meta defines the color data, and all within the circle of radius 0.23 are invisible in my example.

References: pgfplots manual section "Interrupted Plots using Unbounded Coordinate Values"

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.