绘制相同指数时出现奇怪的不对称现象?

绘制相同指数时出现奇怪的不对称现象?

而不是预期的对称形状:

在此处输入图片描述

我从这段代码中得到了什么:

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}

\begin{document}

   \newcommand{\vandbarrierdel}[1]{ 
      \node at (#1, 1.9) {\scriptsize $U_0$};
   }

   \begin{tikzpicture}
       \fill[gray]  
           (0, 0) rectangle (2.8, 4)
           (3.2, 0) rectangle (6, 4)
           (2.8, 0) rectangle (3.2, 2);

       \vandbarrierdel{2.6}

       \draw[red, thick] plot[variable = \x, domain = -3 : 0, smooth] ({\x + 3}, {2.0 + exp{\x*2}});
       \draw[red, thick] plot[variable = \x, domain =  0 : 3, smooth] ({\x + 3}, {2.0 + exp{-\x*2}});

       \node[anchor = north] at (3, 4.5) {\scriptsize $0$};
       \node[anchor = north] at (6, 4.5) {\scriptsize $x$};
       \draw[<->] (0, 4) to (6, 4);
       \draw[-] (2.8, 2) to (2.8, 4);
       \draw[-] (3.2, 2) to (3.2, 4);
       \draw[-] (2.8, 2) to (3.2, 2);
   \end{tikzpicture} 
\end{document}

是:

在此处输入图片描述

为什么会这样?如何修正才能对称?


答案1

这只是一个语法错误。你忘记了 参数周围的括号exp

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}

\begin{document}

   \newcommand{\vandbarrierdel}[1]{ 
      \node at (#1, 1.9) {\scriptsize $U_0$};
   }

   \begin{tikzpicture}
       \fill[gray]  
           (0, 0) rectangle (2.8, 4)
           (3.2, 0) rectangle (6, 4)
           (2.8, 0) rectangle (3.2, 2);

       \vandbarrierdel{2.6}

       \draw[red, thick] plot[variable = \x, domain = -3 : 0, smooth] ({\x + 3}, {2.0 + exp(\x*2)});
       \draw[red, thick] plot[variable = \x, domain =  0 : 3, smooth] ({\x + 3}, {2.0 + exp(-\x*2)});

       \node[anchor = north] at (3, 4.5) {\scriptsize $0$};
       \node[anchor = north] at (6, 4.5) {\scriptsize $x$};
       \draw[<->] (0, 4) to (6, 4);
       \draw[-] (2.8, 2) to (2.8, 4);
       \draw[-] (3.2, 2) to (3.2, 4);
       \draw[-] (2.8, 2) to (3.2, 2);
   \end{tikzpicture} 
\end{document}

在此处输入图片描述

相关内容