可以通过 来更改引脚线与图之间的距离inner sep
。如何更改引脚标签与引脚线之间的距离?
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5.1}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[domain=1:6]
{exp(x)};
54.59815
\node[coordinate,pin={[pin edge={blue,ultra thick}]left:{A pin!} } ]
at (axis cs:4,54.59815) {};
\end{axis}
\end{tikzpicture}
\end{document}
结果是:
如何获得这样的东西:
答案1
您必须在选项inner sep=0pt
后面添加该选项left
。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[domain=1:6]
{exp(x)};
54.59815
\node[coordinate,pin={[pin edge={blue,ultra thick}]left,inner sep=0pt:{A pin!}} ]
at (axis cs:4,54.59815) {};
\end{axis}
\end{tikzpicture}
\end{document}
为了全局定义此属性,您可以定义自己的图钉样式,并以文本标签作为参数,如下所示:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\tikzset{mypin/.style={coordinate,pin={[pin edge={blue,ultra thick}]left,inner sep=0pt:{#1}}}}
\begin{tikzpicture}
\begin{axis}
\addplot[domain=1:6]
{exp(x)};
\node[mypin={A pin!}] at (axis cs:4,54.59815) {};
\node[mypin={Another pin!}] at (axis cs:5,148,41) {};
\end{axis}
\end{tikzpicture}
\end{document}