0

I have the function |x||y-2| <= 1

How would I plot this on latex? I have seen a question posted today that is similar to this, however the graph produced by this function is more complex. So the method used in that question won't work.

0

1 Answer 1

4

Perhaps like this?

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
  \begin{axis}
    [
    restrict z to domain=0:1
    ]

    \addplot3[surf]
    {
      abs(x)*abs(y-2)
    };
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

With truncation it looks a little ugly. However, one could use capping

restrict z to domain*=0:1

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .