2

I am trying to plot the paraboloid z = x^2+y^2+2 with the following code:

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usetikzlibrary{3d}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={135}{10},axis lines = middle]
    \addplot3[surf] (x,y,x^2+y^2+2);
\end{axis}
\end{tikzpicture}
\end{document}

However, pgfplot seems to ignore the z-shift by 2:

enter image description here

I tried various things without any success, my paraboloid is stuck at the origin.

Any help will be appreciated

Stefan Pinnow
  • 29,535

1 Answers1

1

Set a minimum value for the z-axis.

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usetikzlibrary{3d}
\pgfplotsset{compat=newest}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[view={135}{10},axis lines = middle, zmin=0]
            \addplot3[surf] (x,y,x^2+y^2+2);
        \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

Edson
  • 186
  • Edson: works for me! In hindsight, I got tricked by the fact that I could not see the z-axis in my plot, and (wrongly) assumed that the x- and y-axis (that I can see) started at the origin. Thanks a lot. – phillip pinon Jan 24 '22 at 02:30