Tikzpicture 无限曲线绘制

Tikzpicture 无限曲线绘制

我正在使用 LaTeX 绘制椭圆曲线tikzpicture。我在图片上得到了图形,曲线定义为 -2,但我不知道为什么图形没有完成。

在此处输入图片描述

以下是代码:

\begin{tikzpicture}
\begin{axis}[
        xmin=-4,
        xmax=5,
        ymin=-5,
        ymax=5,
        xlabel={$x$},
        ylabel={$y$},
        scale only axis,
        axis lines=middle,
        domain=-1.912931:3,      
        samples=200,
        smooth,   
        clip=false,
        % use same unit vectors on the axis
        axis equal image=true,
    ]
\addplot[blue] {sqrt(x^3-3*x+5)} node[right] {$E$};
\addplot[blue] {-sqrt(x^3-3*x+5)};
\coordinate[label={10:$P$}] (P) at (axis cs:-1,2.64);
\end{axis}
\end{tikzpicture}

答案1

您选择了 的域-1.912931:3。使用更正后的域,它(几乎)可以工作(来自https://www.wolframalpha.com/input/?i=abs(sqrt(x^3-3*x%2B5))+%3D+0)。

功能

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
        xmin=-4,
        xmax=5,
        ymin=-5,
        ymax=5,
        xlabel={$x$},
        ylabel={$y$},
        scale only axis,
        axis lines=middle,
        domain=-2.279018:3,      
        samples=201,
        smooth,   
        clip=false,
        % use same unit vectors on the axis
        axis equal image=true,
    ]
\addplot[blue] {sqrt(x^3-3*x+5)} node[right] {$E$};
\addplot[blue] {-sqrt(x^3-3*x+5)};
\coordinate[label={10:$P$}] (P) at (axis cs:-1,2.64);
\end{axis}
\end{tikzpicture}
\end{document}

答案2

仅说明你在做什么:

在此处输入图片描述

蓝线属于你的 mwe,红线位于未定义的域:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
        xmin=-3,    xmax=5,
        ymin=-5,    ymax=5,
        xlabel={$x$},
        ylabel={$y$},
        scale only axis,
        axis lines=middle,
        clip=false,
        domain=-2.279:3,    % <-- as sugested by TeXnician
        samples=101,
        % use same unit vectors on the axis
        axis equal image=true,
    ]
\addplot[red,domain=-2.279:-2]  {sqrt(x^3-3*x+5)};
\addplot[blue,domain=-2:3]      {sqrt(x^3-3*x+5)} node[right] {$E$};
\addplot[red,domain=-2.279:-2]  {-sqrt(x^3-3*x+5)};
\addplot[blue,domain=-2:3]      {-sqrt(x^3-3*x+5)};
\coordinate[pin=120:{$(-2.279,0)$}]     (aux) at (-2.279,0);
\coordinate[pin=120:{$(-2,\sqrt{3})$}]  (aux) at (-2,1.73205);
\draw[densely dashed, very thin] (-2,-5) -- (-2,5);
\coordinate[label={10:$P$}] (P) at (-1,2.64);
\end{axis}
\end{tikzpicture}
\end{document}

相关内容