我想在一幅图上画两个图钉:
\documentclass{standalone}
\usepackage{pgfplots,tikz}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot {x^2} node[pos=1,pin={[pin distance=0.5em, rounded corners, red, draw=red, fill=red!10!white]20:{$c$}}] {}
node[pos=0.8,pin={[pin distance=0.5em, rounded corners, red, draw=red, fill=red!10!white]20:{$c$}}] {};
\end{axis}
\end{tikzpicture}
\end{document}
如您所见,右上角的图钉位于轴的后面,因此被裁剪,部分内容无法读取。有没有办法改变节点的 z 轴顺序,使图钉位于图像其余部分的前面,这样就不会被裁剪?
答案1
您可以添加选项clip=false
,axis
然后会看到完整的pin
。您的顶部引脚不是behind
轴,而只是partially outside
。
\documentclass{standalone}
\usepackage{pgfplots,tikz}
\begin{document}
\begin{tikzpicture}
\begin{axis}[clip=false]
\addplot {x^2} node[pos=1,pin={[pin distance=0.5em, rounded corners, red, draw=red, fill=red!10!white]20:{$c$}}] {}
node[pos=0.8,pin={[pin distance=0.5em, rounded corners, red, draw=red, fill=red!10!white]20:{$c$}}] {};
\end{axis}
\end{tikzpicture}
\end{document}