如何解决“包 tikz 错误:放弃此路径。您忘记了分号吗?”?

如何解决“包 tikz 错误:放弃此路径。您忘记了分号吗?”?

给出此错误信息的代码是

\documentclass[dvipsnames]{standalone}
\usepackage{pgfplots}
\usepackage{tikz-3dplot}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\pgfplotsset{compat=newest}

\begin{document}
\tdplotsetmaincoords{130}{130}
\begin{tikzpicture}[tdplot_main_coords,scale=.8]
    \begin{axis}[axis lines=middle,height=12cm,xtick=\empty,ytick=\empty,hide axis]
    %------------------------------------- Gráficos -------------------------------------
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (e^(x),e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (-e^(x),e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (e^(x),-e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (-e^(x),-e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (2*e^(x),2*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (-2*e^(x),2*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (2*e^(x),-2*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (-2*e^(x),-2*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (3*e^(x),3*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (-3*e^(x),3*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (3*e^(x),-3*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (-3*e^(x),-3*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (4*e^(x),4*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (-4*e^(x),4*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (4*e^(x),-4*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (-4*e^(x),-4*e^(-x));
        \addplot[,ytick=\empty,yticklabel=\empty,White,domain=-8:10,samples=20] plot (x,0);
        \addplot[,ytick=\empty,yticklabel=\empty,White,domain=-8.5:10,samples=20] plot (0,x);
    % -------------------------------------- Setas --------------------------------------
        \begin{scope}[thick,decoration={markings,mark=at position 0.8 with {\arrow{>}}}]
            \draw[postaction={decorate}] plot [smooth] coordinates {(8.5,0) (0,0)};
            \draw[postaction={decorate}] plot [smooth] coordinates {(-8.5,0) (0,0)};
            \node[scale=2] (x) at (9.3,0) {$\lambda_1$};
        \end{scope}
        \begin{scope}[thick,decoration={markings,mark=at position 0.28 with {\arrow{>}}}]
            \draw[postaction={decorate}] plot [smooth] coordinates {(0,0) (0,8.5)};
            \draw[postaction={decorate}] plot [smooth] coordinates {(0,0) (0,-8.5)};
            \node[scale=2] (y) at (0,9.3) {$\lambda_2$};
        \end{scope}
    \end{axis}
\end{tikzpicture}

\end{document}

我做了一个测试,删除部分代码,然后重新放上去。删除后错误消息不再显示的部分是:

\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (e^(x),e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (-e^(x),e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (e^(x),-e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (-e^(x),-e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (2*e^(x),2*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (-2*e^(x),2*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (2*e^(x),-2*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (-2*e^(x),-2*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (3*e^(x),3*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (-3*e^(x),3*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (3*e^(x),-3*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (-3*e^(x),-3*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (4*e^(x),4*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (-4*e^(x),4*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (4*e^(x),-4*e^(-x));
\addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (-4*e^(x),-4*e^(-x));

所以我替换了所有分号,但错误消息仍然存在。我的代码有问题吗?

提前致谢

答案1

该错误是由圆括号引起的:

语法是\addplot[] ( e^x , e^-x);而不是\addplot[] ( e^(x) , e^(-x))

如果需要圆括号,()则需要将表达式嵌入花括号中,{}例如\addplot[] ({e^(x)},{e^(-x)});

\documentclass[dvipsnames]{standalone}
\usepackage{pgfplots}
\usepackage{tikz-3dplot}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\pgfplotsset{compat=newest}

\begin{document}
\tdplotsetmaincoords{130}{130}
\begin{tikzpicture}[tdplot_main_coords,scale=.8]
    \begin{axis}[axis lines=middle,height=12cm,xtick=\empty,ytick=\empty,hide axis]
    %------------------------------------- Gráficos -------------------------------------
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (e^x,e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (-e^x,e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (e^x,-e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/1):ln(e^2/1),samples=1000] plot (-e^x,-e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (2*e^x,2*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (-2*e^x,2*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (2*e^x,-2*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/2):ln(e^2/2),samples=1000] plot (-2*e^x,-2*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (3*e^x,3*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (-3*e^x,3*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (3*e^x,-3*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/3):ln(e^2/3),samples=1000] plot (-3*e^x,-3*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (4*e^x,4*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (-4*e^x,4*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (4*e^x,-4*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,thick,domain=-ln(e^2/4):ln(e^2/4),samples=1000] plot (-4*e^x,-4*e^-x);
        \addplot[,ytick=\empty,yticklabel=\empty,White,domain=-8:10,samples=20] plot (x,0);
        \addplot[,ytick=\empty,yticklabel=\empty,White,domain=-8.5:10,samples=20] plot (0,x);
    % -------------------------------------- Setas --------------------------------------
        \begin{scope}[thick,decoration={markings,mark=at position 0.8 with {\arrow{>}}}]
            \draw[postaction={decorate}] plot [smooth] coordinates {(8.5,0) (0,0)};
            \draw[postaction={decorate}] plot [smooth] coordinates {(-8.5,0) (0,0)};
            \node[scale=2] (x) at (9.3,0) {$\lambda_1$};
        \end{scope}
        \begin{scope}[thick,decoration={markings,mark=at position 0.28 with {\arrow{>}}}]
            \draw[postaction={decorate}] plot [smooth] coordinates {(0,0) (0,8.5)};
            \draw[postaction={decorate}] plot [smooth] coordinates {(0,0) (0,-8.5)};
            \node[scale=2] (y) at (0,9.3) {$\lambda_2$};
        \end{scope}
    \end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

与 @Roland 的精彩回答无关。OP 代码可以更短更简单:

\documentclass[dvipsnames]{standalone}
\usepackage{pgfplots}
\usepackage{tikz-3dplot}
\usetikzlibrary{decorations.markings}
\pgfplotsset{compat=1.18}

\begin{document}
\tdplotsetmaincoords{130}{130}
\begin{tikzpicture}[tdplot_main_coords,scale=.8]
    \begin{axis}[
height=12cm,
axis lines=middle,
hide axis,
clip=false,
xtick=\empty,
ytick=\empty,
%
samples=101,
every axis plot post/.append style={thick}
                ]
    %------------------------------------- Gráficos -------------------------------------
        \addplot[domain=-ln(e^2/1):ln(e^2/1)] plot (e^x,e^-x);
        \addplot[domain=-ln(e^2/1):ln(e^2/1)] plot (-e^x,e^-x);
        \addplot[domain=-ln(e^2/1):ln(e^2/1)] plot (e^x,-e^-x);
        \addplot[domain=-ln(e^2/1):ln(e^2/1)] plot (-e^x,-e^-x);
        \addplot[domain=-ln(e^2/2):ln(e^2/2)] plot (2*e^x,2*e^-x);
        \addplot[domain=-ln(e^2/2):ln(e^2/2)] plot (-2*e^x,2*e^-x);
        \addplot[domain=-ln(e^2/2):ln(e^2/2)] plot (2*e^x,-2*e^-x);
        \addplot[domain=-ln(e^2/2):ln(e^2/2)] plot (-2*e^x,-2*e^-x);
        \addplot[domain=-ln(e^2/3):ln(e^2/3)] plot (3*e^x,3*e^-x);
        \addplot[domain=-ln(e^2/3):ln(e^2/3)] plot (-3*e^x,3*e^-x);
        \addplot[domain=-ln(e^2/3):ln(e^2/3)] plot (3*e^x,-3*e^-x);
        \addplot[domain=-ln(e^2/3):ln(e^2/3)] plot (-3*e^x,-3*e^-x);
        \addplot[domain=-ln(e^2/4):ln(e^2/4)] plot (4*e^x,4*e^-x);
        \addplot[domain=-ln(e^2/4):ln(e^2/4)] plot (-4*e^x,4*e^-x);
        \addplot[domain=-ln(e^2/4):ln(e^2/4)] plot (4*e^x,-4*e^-x);
        \addplot[domain=-ln(e^2/4):ln(e^2/4)] plot (-4*e^x,-4*e^-x);
    % -------------------------------------- Setas --------------------------------------
        \begin{scope}[decoration={markings,mark=at position 0.8 with {\arrow[very thick]{>}}}]
            \draw[postaction={decorate}] (8.5,0) node[right, scale=2] {$\lambda_1$} -- (0,0);
            \draw[postaction={decorate}] (0,8.5) node[above, scale=2] {$\lambda_2$} -- (0,0);
            \draw[postaction={decorate}] (-8.5,0) -- (0,0);
            \draw[postaction={decorate}] (0,-8,5) -- (0,0); 
        \end{scope}
    \end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容