1

I want to use pins to comment specific points in a diagramm. When I use a edge like -> it works fine. But if I use *- for example then the center of the dot is not at the position it should be. Maybe it's a problem with the anchor. Here is an example:

\documentclass[]{article}

\usepackage{tikz}
\usepackage{pgfplots}
\usepgflibrary{arrows}

\begin{document}

\begin{tikzpicture}
\begin{axis}%
[
axis y line = left,
axis x line = middle,
grid
]
\addplot[mark=none,domain=0:5] {x}; 
\node%
[
coordinate,
pin={[pin edge={*-}]50:{text}}
] 
at (axis cs:2,1) {};
%
\node%
[
coordinate,
pin={[pin edge={red}]-50:{text}}
] 
at (axis cs:2,1) {};
\end{axis}
\end{tikzpicture}

\end{document}

Leading to

enter image description here

The close up shows the problem:

enter image description here

Any ideas?

  • Center of the dot is not relevant. The arrow head is the whole circle and it's computed to touch the target point not land on it. If you want circle on the target put a circle node and apply pin on that particular node. – percusse May 20 '13 at 17:21
3

This happens because the circle is treated like an arrow head, so it is flush with the end of the line. You can use the shorten < syntax (see Modifying * and o style tikz arrows so that they are centered at the end of line) to manually adjust the position, or you can define a new arrow tip (based on the standard one) to position the circle precisely on the specified coordinate:

\documentclass[]{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\usepgflibrary{arrows}

\makeatletter
\pgfarrowsdeclare{center*}{center*}
{
  \pgfutil@tempdima=0.4pt%
  \advance\pgfutil@tempdima by.2\pgflinewidth%
  \pgfutil@tempdimb=5.5\pgfutil@tempdima\advance\pgfutil@tempdimb by\pgflinewidth
  \pgfarrowsleftextend{0pt}
  \pgfutil@tempdimb=1.5\pgfutil@tempdima\advance\pgfutil@tempdimb by.5\pgflinewidth
  \pgfarrowsrightextend{0pt}
}
{
  \pgfutil@tempdima=0.4pt%
  \advance\pgfutil@tempdima by.2\pgflinewidth%
  \pgfsetdash{}{+0pt}
  \pgfpathcircle{\pgfqpoint{0pt}{0pt}}{+4.5\pgfutil@tempdima}
  \pgfusepathqfillstroke
}

\makeatother

\begin{document}

\begin{tikzpicture}
\begin{axis}%
[
axis y line = left,
axis x line = middle,
grid
]
\addplot[mark=none,domain=0:5] {x}; 
\node%
[
coordinate,
pin={[pin edge={center*-}]50:{text}}
] 
at (axis cs:2,1) {};
%
\node%
[
coordinate,
pin={[pin edge={red}]-50:{text}}
] 
at (axis cs:2,1) {};
\end{axis}

\end{tikzpicture}

\end{document}
  • Thanks for the answer. I thought there might be an easier way. Damn. – Dr. Manuel Kuehner May 20 '13 at 17:28
  • @ManuelKuehner: Well, the shorten < option is pretty easy. – Jake May 20 '13 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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