如何使用 pgfplots 绘制正态曲线

如何使用 pgfplots 绘制正态曲线

我只创建这个:

在此处输入图片描述

有了这个

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{fillbetween}

\begin{document}

\begin{center}
\begin{tikzpicture}
\begin{axis}[ymin = 0, axis x line = bottom, axis y line=middle, 
         legend pos=outer north east]
\addplot [name path=A, domain=0:6,cyan, thick]{x};

%\legend{$f(x)=x^2$, $g(x)$}

%\path [name path=yaxis] (0,0)--(0,1000);  %<---- third path

\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

我想要这个图像(我不关心 f(x),我只关心形式): 在此处输入图片描述

有任何想法吗非常感谢

答案1

下面是基于您自己的代码的示例,它可能会实现您所期望的功能:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{fillbetween}

\begin{document}

\begin{center}
\pgfmathdeclarefunction{normalcurve}{0}{\pgfmathparse{1.5*1/exp(((x-3)^2)/2)}}
\begin{tikzpicture}
\begin{axis}[xlabel=$V$, ylabel=$P$,
        xlabel style={at=(current axis.right of origin), anchor=west},
        ylabel style={at=(current axis.above origin), anchor=south},
        ticks=none, ymin = 0, ymax=1.6, axis x line = bottom, axis y line=middle,
         legend pos=outer north east]
\addplot [name path=A, domain=0:6,cyan, thick, samples=150] {normalcurve};
\draw[dashed] (3,1.5) -- (3,0);
\node at (3,1.5) {\textbullet};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

结果如下:

![在此处输入图片描述

该代码还有待改进,希望有用。

相关内容