[Tex/LaTex] How to change the distance between a pin label and the pin line

nodespgfplotstikz-pgf

The distance between the pin line and the plot can be changed by inner sep. How to change the distance between the pin label and the pin line?

\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}

Results in:

enter image description here

How to get something like this:

enter image description here

Best Answer

You have to add the inner sep=0pt option after the left one.

\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}

enter image description here

For defining this property globally you can define your own pin style that takes the text label as argument in this way:

\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}

enter image description here