0

I annotate special points in my diagram and use a node/pin approach:

\documentclass[border=3mm,tikz]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis lines = middle,
    xlabel = {$x$},
    ylabel = {$y$},
        ]
    \addplot [domain=0:10]{x};
    \node[coordinate, pin={[align=left,pin distance = 10mm]-30:{Test Text Test\\ Text Test}}]
               at (axis cs:4,4) {};
\end{axis}
\end{tikzpicture}
\end{document}

I want to change the anchor for the pin line / pin egde -- here are two possibilities:

enter image description here

Is that possible?

4
  • @gonzalo-medina Are you sure this is a duplicate to the question you referred to? Sep 4, 2015 at 18:04
  • Yes; I'm completely sure. I myself tested the proposed code in the answer using your example code and allows you to do what you want. Sep 4, 2015 at 18:10
  • I see it now - took me a minute :). Seems complicated. Thank you very much. When I searched the forum I did not find it. So basically there's no "out of the box" way. Sep 4, 2015 at 18:11
  • No, no "out of the box" way. Sep 4, 2015 at 18:16

1 Answer 1

1

An alternative for pin is to place the text node directly, at the position you want. The the line can be drawn between the point on the curve and the node. Variant 1 connects to the west of the text node and variant 2 to the north.

Example:

\documentclass[border=3mm,tikz]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis lines = middle,
    xlabel = {$x$},
    ylabel = {$y$},
        ]
    \addplot [domain=0:10]{x};
    \draw
      (axis cs:3, 3) coordinate (tmp) % start point
      ++(-30:5mm)
      node[
        below right,
        align=left,
      ] (test) {Test Text Test\\Text Test}
      (test.west) -- (tmp)
    ;
    \draw
      (axis cs:6, 6) coordinate (tmp) % start point
      ++(-30:5mm)
      node[
        below right,
        align=left,
      ] (test) {Test Text Test\\Text Test}
      (test.north) -- (tmp)
    ;
\end{axis}
\end{tikzpicture}
\end{document}

Result

1
  • Thanks a lot Heiko. I would prefer a node/pin solution since it is less code and I like the elegance. But if there isn't a way then I do not have another choice. Sep 4, 2015 at 18:06

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