Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following example from the pgfplot manual.

\begin{tikzpicture}
  \tikzset{
    every pin/.style={fill=yellow!50!white,rectangle,rounded corners=3pt,font=\tiny},
    small dot/.style={fill=black,circle,scale=0.3}
  }
  \begin{axis}[
    clip=false,
    title=How \texttt{axis description cs} works
  ]
  \addplot {x};

  \node[small dot,pin=120:{$(0,0)$}]
  \node[small dot,pin=-30:{$(1,1)$}]
  \node[small dot,pin=-90:{$(1.03,0.5)$}]
  \node[small dot,pin=125:{$(0.5,0.5)$}]
  \end{axis}
\end{tikzpicture}

That code gives the following image

image produced by above code

What I want to change and I couldn't found in the manual is to change the length of the pins. For example make the text of the pin in the middle appear closer to the value 5 of the y axis and make the connecting line extent to that point. The result I want appears in the following picture.

enter image description here

Is that possible somehow?

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

You can use pin distance:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
  \tikzset{
    every pin/.style={fill=yellow!50!white,rectangle,rounded corners=3pt,font=\tiny},
    small dot/.style={fill=black,circle,scale=0.3}
  }
  \begin{axis}[
    clip=false,
    title=How \texttt{axis description cs} works
  ]
  \addplot {x};

  \node[small dot,pin=120:{$(0,0)$}] at (axis description cs:0,0) {};
  \node[small dot,pin=-30:{$(1,1)$}] at (axis description cs:1,1) {};
  \node[small dot,pin={[pin distance=2cm]125:{$(0.5,0.5)$}}] at (axis description cs:0.5,0.5) {};
  \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.