绘制多个水平高斯钟形移位 ik TikZ

绘制多个水平高斯钟形移位 ik TikZ

我想创建类似的东西来说明线性模型。 在此处输入图片描述 这是我迄今为止使用 Mathcha 生成的代码,只是为了了解我想要什么。

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-0.75,xscale=0.75]
        %uncomment if require: \path (0,300); %set diagram left start at 0, and has height of 300

        %Shape: Axis 2D [id:dp8361200068338723]
        \draw  (50,250.04) -- (610.41,250.04)(106.04,11.54) -- (106.04,276.54) (603.41,245.04) -- (610.41,250.04) -- (603.41,255.04) (101.04,18.54) -- (106.04,11.54) -- (111.04,18.54)  ;
        %Straight Lines [id:da4842290347914763]
        \draw [color={rgb, 255:red, 74; green, 144; blue, 226 }  ,draw opacity=1 ]   (551.41,21.04) -- (44.91,263.54) ;
        %Curve Lines [id:da2882365205325442]
        \draw [fill={rgb, 255:red, 126; green, 211; blue, 33 }  ,fill opacity=1 ]   (172,159.74) .. controls (181.41,184.64) and (210.41,154.64) .. (219.41,178.64) .. controls (228.41,202.64) and (197.91,206.64) .. (204.91,226.64) ;
        %Curve Lines [id:da35238413522248413]
        \draw [fill={rgb, 255:red, 126; green, 211; blue, 33 }  ,fill opacity=1 ]   (284,107.24) .. controls (293.41,132.14) and (322.41,102.14) .. (331.41,126.14) .. controls (340.41,150.14) and (309.91,154.14) .. (316.91,174.14) ;
        %Curve Lines [id:da8161792691558291]
        \draw [fill={rgb, 255:red, 126; green, 211; blue, 33 }  ,fill opacity=1 ]   (403,51.74) .. controls (412.41,76.64) and (441.41,46.64) .. (450.41,70.64) .. controls (459.41,94.64) and (428.91,98.64) .. (435.91,118.64) ;

        % Text Node
        \draw (112.5,19.4) node [anchor=north west][inner sep=0.75pt]    {$y$};
        % Text Node
        \draw (584,250.9) node [anchor=north west][inner sep=0.75pt]    {$z_{1}$};
        % Text Node
        \draw (538.5,30.9) node [anchor=north west][inner sep=0.75pt]  [font=\footnotesize,color={rgb, 255:red, 74; green, 144; blue, 226 }  ,opacity=1 ]  {$y=\beta _{0} +\beta _{1} z_{1}$};
        % Text Node
        \draw (537.5,67.74) node [anchor=north west][inner sep=0.75pt]  [font=\footnotesize] [align=left] {$\displaystyle \forall z_{i}$ prendo \\valori \textcolor[rgb]{0.49,0.83,0.13}{qui dentro}};
    \end{tikzpicture}

我知道如何在纯 TikZ(即不使用 Mathcha)中生成轴和线,但我不知道如何生成高斯钟形图。

答案1

正如 Qrrbrbirlbel 在评论中所说,您只需要plot高斯曲线和shift它、rotate它和scale它即可。

起点可以是:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[line cap=round,scale=2]
\coordinate (A) at (-0.5,-0.1);
\draw[-stealth] (-0.5,0) -- (5,0)  node[below] {$z_1$};
\draw[-stealth] (0,-0.5) -- (0,3)  node[left]  {$y$};
\draw[blue]     (A)    --++ (30:6) node[below right] {$y=\beta_0+\beta_1z_1$};
\node[text width=3cm,right] at (4.7,2) {$\forall z_1$ prendo\\valori \textcolor{green}{qui dentro}};
\foreach\i in {1.5,3,4.5}
  \draw[shift={($(A)+(30:\i)$)},scale=0.4,rotate=-60,fill=green] plot[domain=-1.5:1.5,samples=41] (\x,{exp(-2*\x*\x)});
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容