![pgfplots:让绘图继续,直到扩大极限](https://linux22.com/image/387817/pgfplots%EF%BC%9A%E8%AE%A9%E7%BB%98%E5%9B%BE%E7%BB%A7%E7%BB%AD%EF%BC%8C%E7%9B%B4%E5%88%B0%E6%89%A9%E5%A4%A7%E6%9E%81%E9%99%90.png)
我希望情节一直延续到扩大的极限,而轴刻度不移动。有什么想法吗?
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\begin{document}
\begin{figure}[ht]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
every axis plot post/.append style={
mark=none,domain=-4:4,samples=100,smooth},
xtick={-4,-3,...,4},
grid=both,
axis x line=bottom,
axis y line=left,
enlargelimits=upper]
\addplot[black!100]{gauss(2,0.75)} node[pos=0.87] (h1) {};
\node [right,black] at (h1) {$h_1$};
\path[] (axis cs:0,0) -- (axis cs:4,0);
\end{axis}
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}
谢谢你!
答案1
删除该选项enlargelimits
,否则当你增加域时它将继续增加画布的大小
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\begin{document}
\begin{figure}[ht]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
every axis plot post/.append style={
mark=none,domain=-4:4.9,samples=100,smooth},
xtick={-4,-3,...,4},
grid=both,
axis x line=bottom,
axis y line=left,
]
\addplot[black!100]{gauss(2,0.75)} node[pos=0.87] (h1) {};
\node [right,black] at (h1) {$h_1$};
\path[] (axis cs:0,0) -- (axis cs:4,0);
\end{axis}
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}