I'm trying to plot the function $-log(x^2+y^2)$ in a circular domain centered in (0,0).
With addplot3
I can plot it on the square domain $[-1,1]^2$.
With what I found here pgfplots and ifthenelse, I can choose to set the value to 0 outside of the disk, but I'd like nothing to be drawn at all.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{amsmath}
\pgfmathdeclarefunction{ifthenelsefpu}{3}{%
\pgfmathparse{#1*#2 + !#1*#3}%
}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot3[
surf,
samples = 60,
domain = -1:1,
y domain = -1:1,
] ({x}, {y}, {ifthenelsefpu({(x^2+y^2<=1)}, -ln(sqrt(x^2 + y^2)), 0)});
\end{axis}
\end{tikzpicture}
\end{document}
We see on the external part of the disk that the plot is flat.
When I replace the 0
by nan
in the macro ifthenelsefpu
, I get the error Package pgfplots: An internal error occured during z buffer reorderings: the rows/cols where not balanced! I have rows= 60, cols=60. If this happens to be wrong, you might want to provide rows and cols manually..
How can I achieve to make this figure ?