![Pgfplots 节点定位行为异常](https://linux22.com/image/369764/Pgfplots%20%E8%8A%82%E7%82%B9%E5%AE%9A%E4%BD%8D%E8%A1%8C%E4%B8%BA%E5%BC%82%E5%B8%B8.png)
简单来说,这是为什么:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
clip=false,
ticks=none,
axis y line=none,
axis x line=middle,
xlabel=$x$,
xlabel style={anchor=west}
]
\addplot+[ycomb] plot coordinates { (3,2) };
\node[anchor=north] at (axis cs: 3,0 ) {$x_\circ$};
\end{axis}
\end{tikzpicture}
\end{document}
制作这个:
我希望看到的是蓝色茎正下方的 $x_\circ$。这是怎么回事?我做错了什么?
答案1
问题在于轴范围。只需添加选项ymin=0
,它就会按预期运行:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
clip=false,
ticks=none,
axis y line=none,
axis x line=middle,
xlabel=$x$,
xlabel style={anchor=west},
ymin=0
]
\addplot+[ycomb] plot coordinates { (3,2) };
\node[anchor=north] at (axis cs: 3,0) {$x_\circ$};
\end{axis}
\end{tikzpicture}
\end{document}