如何在此蓝色曲线上添加小凸起状特征(小高斯状特征)?

如何在此蓝色曲线上添加小凸起状特征(小高斯状特征)?

我正在使用以下代码制作下图。我想在蓝色曲线的最上象限添加一些 4-5 个小“凸起”(有点像小的高斯波包),就像这张图片中一样。凸起应该彼此稍微分开,并且应该位于蓝色曲线上。在此处输入图片描述

我到目前为止制作的图表以及代码如下所示。我该怎么做呢?这张照片

\documentclass[convert]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\node (I)    at ( 4,0)   {};
\node (II)   at (-4,0)   {};
\node (III)  at (0, 2.5) {};
\node (IV)   at (0,-2.5) {};

\path  
(II) +(90:4)  coordinate[label=90:]  (IItop)
   +(-90:4) coordinate[label=-90:] (IIbot)
   +(0:4)   coordinate                  (IIright)
   +(180:4) coordinate[label=180:] (IIleft);

\draw (IItop) --(IIright) -- (IIbot)--cycle;


\path 
(I) +(90:4)  coordinate (Itop)
   +(-90:4) coordinate (Ibot)
   +(180:4) coordinate (Ileft)
   +(0:4)   coordinate (Iright);


\draw  (Ileft) -- (Itop) -- (Ibot) -- (Ileft) -- cycle;

% Squiggly lines
\draw[decorate,decoration=zigzag, red, thick] (IItop) -- (Itop)
  node[midway, above, inner sep=2mm] {};

\draw[decorate,decoration=zigzag, red, thick] (IIbot) -- (Ibot)
  node[midway, below, inner sep=2mm] {};

\draw[blue, thick]   % The -> adds an arrow tip
($(Itop)!.07!(Ibot)$) to[out=220, in=-40, looseness=1.3] ($(IItop)!.07!(IIbot)$);




\draw[fill] ($(Itop)!.07!(Ibot)$) circle [radius=0.05] node[right] {$t$};

\draw[fill] ($(IItop)!.07!(IIbot)$) circle [radius=0.05] node[left] {$t$};


\end{tikzpicture} 

\end{document}

答案1

添加高斯函数最简单的方法可能就是添加高斯函数。也就是说,找到一条可以重现蓝色曲线的解析曲线,然后添加高斯函数。

\documentclass[convert]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[declare function={gauss(\x)=(abs(\x)<2 ? exp(-5*\x*\x):0);}]
\node (I)    at ( 4,0)   {};
\node (II)   at (-4,0)   {};
\node (III)  at (0, 2.5) {};
\node (IV)   at (0,-2.5) {};

\path  
(II) +(90:4)  coordinate[label=90:]  (IItop)
   +(-90:4) coordinate[label=-90:] (IIbot)
   +(0:4)   coordinate                  (IIright)
   +(180:4) coordinate[label=180:] (IIleft);

\draw (IItop) --(IIright) -- (IIbot)--cycle;


\path 
(I) +(90:4)  coordinate (Itop)
   +(-90:4) coordinate (Ibot)
   +(180:4) coordinate (Ileft)
   +(0:4)   coordinate (Iright);


\draw  (Ileft) -- (Itop) -- (Ibot) -- (Ileft) -- cycle;

% Squiggly lines
\draw[decorate,decoration=zigzag, red, thick] (IItop) -- (Itop)
  node[midway, above, inner sep=2mm] {};

\draw[decorate,decoration=zigzag, red, thick] (IIbot) -- (Ibot)
  node[midway, below, inner sep=2mm] {};

% \draw[blue, thick]   % The -> adds an arrow tip
% ($(Itop)!.07!(Ibot)$) to[out=220, in=-40, looseness=1.3] ($(IItop)!.07!(IIbot)$);

\draw[blue, thick] plot[variable=\t,domain=-4:4,samples=101] 
(\t,{1.48+\t*\t/8+0.5*gauss(\t-3)+0.5*gauss(\t-1)+0.5*gauss(\t+1)+0.5*gauss(\t+3)});


\draw[fill] ($(Itop)!.07!(Ibot)$) circle [radius=0.05] node[right] {$t$};

\draw[fill] ($(IItop)!.07!(IIbot)$) circle [radius=0.05] node[left] {$t$};


\end{tikzpicture} 

\end{document}

在此处输入图片描述

至于您的评论:

\documentclass[convert]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[declare function={gauss(\x)=(abs(\x)<2 ? exp(-10*\x*\x):0);}]
\node (I)    at ( 4,0)   {};
\node (II)   at (-4,0)   {};
\node (III)  at (0, 2.5) {};
\node (IV)   at (0,-2.5) {};

\path  
(II) +(90:4)  coordinate[label=90:]  (IItop)
   +(-90:4) coordinate[label=-90:] (IIbot)
   +(0:4)   coordinate                  (IIright)
   +(180:4) coordinate[label=180:] (IIleft);

\draw (IItop) --(IIright) -- (IIbot)--cycle;


\path 
(I) +(90:4)  coordinate (Itop)
   +(-90:4) coordinate (Ibot)
   +(180:4) coordinate (Ileft)
   +(0:4)   coordinate (Iright);


\draw  (Ileft) -- (Itop) -- (Ibot) -- (Ileft) -- cycle;

% Squiggly lines
\draw[decorate,decoration=zigzag, red, thick] (IItop) -- (Itop)
  node[midway, above, inner sep=2mm] {};

\draw[decorate,decoration=zigzag, red, thick] (IIbot) -- (Ibot)
  node[midway, below, inner sep=2mm] {};

\draw[blue, thick]   % The -> adds an arrow tip
($(Itop)!.07!(Ibot)$) to[out=220, in=-40, looseness=1.3] ($(IItop)!.07!(IIbot)$);

\draw[red, thick] foreach \X in {-3,-1,1,3}
{plot[variable=\t,domain=\X-0.8:\X+0.8,samples=31] 
(\t,{1.48+\t*\t/6.8-\t*\t*\t*\t/640+0.5*gauss(\t-3)+0.5*gauss(\t-1)+0.5*gauss(\t+1)+0.5*gauss(\t+3)})};


\draw[fill] ($(Itop)!.07!(Ibot)$) circle [radius=0.05] node[right] {$t$};

\draw[fill] ($(IItop)!.07!(IIbot)$) circle [radius=0.05] node[left] {$t$};


\end{tikzpicture} 

\end{document}

在此处输入图片描述

或者只是通过节点添加它们(\savebox节省一些编译时间,否则也pic可以)。

\documentclass[convert]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{calc}
\newsavebox\Gaussian
\sbox\Gaussian{\begin{tikzpicture}[declare function={
    gauss(\x)=(abs(\x)<2 ? exp(-15*\x*\x):0);}]
 \draw[red,thick] plot[smooth,domain=-0.8:0.8] (\x,{0.5*gauss(\x)});
\end{tikzpicture}}
\begin{document}

\begin{tikzpicture}
\node (I)    at ( 4,0)   {};
\node (II)   at (-4,0)   {};
\node (III)  at (0, 2.5) {};
\node (IV)   at (0,-2.5) {};

\path  
(II) +(90:4)  coordinate[label=90:]  (IItop)
   +(-90:4) coordinate[label=-90:] (IIbot)
   +(0:4)   coordinate                  (IIright)
   +(180:4) coordinate[label=180:] (IIleft);

\draw (IItop) --(IIright) -- (IIbot)--cycle;


\path 
(I) +(90:4)  coordinate (Itop)
   +(-90:4) coordinate (Ibot)
   +(180:4) coordinate (Ileft)
   +(0:4)   coordinate (Iright);


\draw  (Ileft) -- (Itop) -- (Ibot) -- (Ileft) -- cycle;

% Squiggly lines
\draw[decorate,decoration=zigzag, red, thick] (IItop) -- (Itop)
  node[midway, above, inner sep=2mm] {};

\draw[decorate,decoration=zigzag, red, thick] (IIbot) -- (Ibot)
  node[midway, below, inner sep=2mm] {};

\draw[blue, thick]   % The -> adds an arrow tip
($(Itop)!.07!(Ibot)$) to[out=220, in=-40, looseness=1.3] 
node[pos=0.1,sloped,above=-3pt]{\usebox\Gaussian}
node[pos=0.35,sloped,above=-2pt]{\usebox\Gaussian}
node[pos=0.65,sloped,above=-2pt]{\usebox\Gaussian}
node[pos=0.9,sloped,above=-3pt]{\usebox\Gaussian}
($(IItop)!.07!(IIbot)$);

\draw[fill] ($(Itop)!.07!(Ibot)$) circle [radius=0.05] node[right] {$t$};

\draw[fill] ($(IItop)!.07!(IIbot)$) circle [radius=0.05] node[left] {$t$};


\end{tikzpicture} 

\end{document}

在此处输入图片描述

相关内容