0

I am failing to display a paraboloid with tikz \addplot3 command. I read a thourough manual that I found online as well as tried to adapt this example, but I don't really understand how to translate my function into polar coordinates, as it seems. The level curves of my paraboloid, with the function equation:

level curves

My code for the 3d-plot:

    \begin{tikzpicture}
    \begin{axis}[
        title={Sammansatta nivåkuror, botten på $(0,0,1)$},
        axis lines=center,
        axis on top,
        colormap/cool,
        xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
    ]
    \addplot3[
        surf,
        samples=50,
        domain=0:360,
        y domain=0:3,
        restrict z to domain=0:10,
        data cs=polar
    ] (x, y, {sqrt(x^2+2*y^2)+1});
    \end{axis}
    \end{tikzpicture}

What it outputs:

enter image description here

What the 3d-plot should look like (but the function is off):

enter image description here

I obtained the latter by modifying the following:

\addplot3[
   ...
] (x, y, y^2)

Also, the last 3d-plot displays up to different values of z depending on my screenwidth, which I do not really understand. I am using Overleaf.

Stefan Pinnow
  • 29,535

1 Answers1

1

If in your formula x and y are cartesian coordinates (as I suppose) then you should not use data cs=polar.

\documentclass{article}
  \usepackage{pgfplots}
  \pgfplotsset{compat=1.16}
  \begin{document}
    \begin{tikzpicture}
       \begin{axis}[
                   title={Sammansatta nivåkuror, botten på $(0,0,1)$},
                   axis lines=center,
                   axis on top,
                   colormap/cool,
                   xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
                   ]
              \addplot3[
                        surf,
                        samples=50,
                        % domain=0:360,
                        % y domain=0:3,
                        % restrict z to domain=0:10,
                        % data cs=polar
                        ] {sqrt(x^2+2*y^2)+1};
                \end{axis}
                \end{tikzpicture}
             \end{document}

enter image description here