pgfplots 线未到达轴

pgfplots 线未到达轴

以下是代码:

\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

但为什么它没有到达另一条线路?

答案1

您不能取sqrt负数。我已调整了您的域名。

\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

相关内容