如何在图的某一部分绘制函数

如何在图的某一部分绘制函数

我想在穿过项目符号的黑线上绘制蓝色“高斯”(使用 sinc 近似),就像它位于实际轴上,中心位于项目符号上方,不接触黑线。比例也应该合适。我该怎么做?

图

以下是代码:

\begin{center}
        \begin{tikzpicture}[scale=1.4]
        \pgfmathdeclarefunction{sinc}{1}{%
        \pgfmathparse{abs(#1)<0.01 ? int(1) : int(0)}%
        \ifnum\pgfmathresult>0 \pgfmathparse{1}\else\pgfmathparse{sin(#1 r)/#1}\fi%
        }
        
        \def\x{1} % replace 1 with desired value here
        \draw[->] (-1.2,0) -- (2.6,0) node[right] {$\Psi_1$};
        \draw[->] (0,-1.2) -- (0,2.6) node[above left] {$\Psi_2$};

        \draw[-] (1.1,1.5) -- (1.9,1.5);

        \foreach \Point in { (1.5,1.5)}{
        \node at \Point {\textbullet};}
        
        \draw[blue,domain=-1.3:1.3,samples=202,smooth] plot (\x,{2*sinc(2.1*\x)});

        \node (A) at (1.99, 1.29) {\footnotesize$S_m$};

         \foreach \Point in { (1.66,1.35), (1.56,1.25),(1.45,1.19),(1.62,1.41),(1.76,1.35),(1.76,1.65),(1.26,1.25),(1.4,1.42),(1.46,1.85),(1.56,1.6),(1.46,1.75),(1.32,1.3),(1.39,1.55),(1.28,1.47),(1.36,1.4),(1.39,1.65),(1.22,1.61) }{
        \node at \Point {\tiny $\ast$};} 
        
    \end{tikzpicture}
\end{center}

答案1

感谢@John Kormylo 链接到另一个问题,这对我弄清楚这个问题很有帮助。

以下是工作代码:

\begin{center}
        \tikzstyle{hidden}=[circle,fill=white!25,minimum size=50pt,inner sep=0pt, path picture={
            \draw[blue,thick,-] plot[domain=-0.4:0.4,samples=15,smooth] ({\x},{0.3*g(\x)});
        },]
        
        \begin{tikzpicture}[scale=1.6]
        \pgfmathdeclarefunction{sinc}{1}{%
        \pgfmathparse{abs(#1)<0.01 ? int(1) : int(0)}%
        \ifnum\pgfmathresult>0 \pgfmathparse{1}\else\pgfmathparse{sin(#1 r)/#1}\fi%
        }
        
        \def\x{1} % replace 1 with desired value here
        \draw[->] (-1,0) -- (2.6,0) node[right] {$\Psi_1$};
        \draw[->] (0,-1) -- (0,2.6) node[above left] {$\Psi_2$};
        
        \node (h)[hidden] at (1.5, 1.5){};
        
        \foreach \Point in { (1.5,1.5)}{
        \node at \Point {\textbullet};}
        
        \node (A) at (1.99, 1.29) {\footnotesize$S_m$};

         \foreach \Point in { (1.66,1.35), (1.56,1.25),(1.45,1.19),(1.62,1.41),(1.76,1.35),(1.76,1.65),(1.26,1.25),(1.4,1.42),(1.46,1.85),(1.56,1.6),(1.49,1.75),(1.32,1.3),(1.39,1.55),(1.28,1.47),(1.36,1.4),(1.39,1.65),(1.22,1.61) }{
        \node at \Point {\tiny $\ast$};} 
        
    \end{tikzpicture}
\end{center}

高斯的定义可以在链接的问题中找到!

相关内容