1

Here is the code:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
 \begin{axis}[
        width=500,
        height=500,
        axis lines = center,
        xlabel = {$x$},
        ylabel = {$y$},
        zlabel = {$z$},
        zmin=-5,
        zmax=0.5,
        xmin=-4,
        xmax=4,
        ymin=-4,
        ymax=4,
        view = {100}{10},
        xtick={-4,0, 4},
        ytick={-4,0,4},
        ztick={0,-3,-5}
        ]
        \addplot3[black, samples=40, domain=-4:4,thick, samples y=0]({x},{0},{(-5*x^2)/16});

        \addplot3[black, samples=40, domain=-4:0,thick]({0},{y},{(-5*y^2)/16});

        \addplot3[black, samples=40,         domain=-4:4,samples y=0    ]({x},{0},{-sqrt(x^2+9)});
        \addplot3[black, samples=40, dashed, domain=-4:0                ]({0},{y},{-sqrt(y^2+9)});

        \addplot3[black, samples=20, dashed, domain=-4:0,samples y=0    ]({x},{-sqrt(-x^2+16)},{-5});
        \addplot3[black, samples=20,         domain= 0:4,samples y=0    ]({x},{-sqrt(-x^2+16)},{-5});

        \addplot3[black, samples=40, dashed, domain=-4:0 ,samples y=0    ]({x},{-sqrt(-x^2+ 9.6)},{-3});
        \addplot3[black, samples=40,         domain= 0:4 ,samples y=0    ]({x},{-sqrt(-x^2+ 9.6))},{-3});

        \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

And why is doesn't reach another line?

2
  • Also, if you know another easier way to draw bodies, like this, please tell me how Commented Dec 14, 2018 at 21:19
  • Please add complete compilable code starting, with \documentclass{... and ending with \end{document}. Commented Dec 14, 2018 at 22:09

1 Answer 1

2

You can not take sqrt of a negative number. I have adjusted your domain.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
 \begin{axis}[
        width=500,
        height=500,
        axis lines = center,
        xlabel = {$x$},
        ylabel = {$y$},
        zlabel = {$z$},
        zmin=-5,
        zmax=0.5,
        xmin=-4,
        xmax=4,
        ymin=-4,
        ymax=4,
        view = {100}{10},
        xtick={-4,0, 4},
        ytick={-4,0,4},
        ztick={0,-3,-5}
        ]
        \addplot3[black, samples=40, domain=-4:4,thick, samples y=0]({x},{0},{(-5*x^2)/16});

        \addplot3[black, samples=40, domain=-4:0,thick]({0},{y},{(-5*y^2)/16});

        \addplot3[black, samples=40,         domain=-4:4,samples y=0    ]({x},{0},{-sqrt(x^2+9)});
        \addplot3[black, samples=40, dashed, domain=-4:0                ]({0},{y},{-sqrt(y^2+9)});

        \addplot3[black, samples=20, dashed, domain=-4:0,samples y=0    ]({x},{-sqrt(-x^2+16)},{-5});
        \addplot3[black, samples=20,         domain= 0:4,samples y=0    ]({x},{-sqrt(-x^2+16)},{-5});

        \addplot3[black, samples=40, dashed, domain=-sqrt(9.6):0 ,samples y=0    ]({x},{-sqrt(-x^2+ 9.6)},{-3});
        \addplot3[black, samples=40,         domain= 0:sqrt(9.6) ,samples y=0    ]({x},{-sqrt(-x^2+ 9.6))},{-3});

        \end{axis}
\end{tikzpicture}
\end{document}

Corrected graph

2
  • How is it possible to have samples y=0 and even the funtion is drawn?
    – manooooh
    Commented Dec 14, 2018 at 22:09
  • @manooooh: I do not know, and I thought it was an error, but it does have some meaning, as it is used in example on page 57 in the manual. Commented Dec 14, 2018 at 22:13

You must log in to answer this question.

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