[Tex/LaTex] Annotating a pgfplots graph

pgfplotstikz-pgf

I tried the solution proposed in : How can/should I include annotated images?

However, the coordinates don't match with the coordinates I used when plotting the diagrams (data coordinates). For example, I have a mesh generated by a python program and matplotlib and I want to annotate it, using the same coordinates I used when plotting the data.

Let's say there is a node in the mesh at coordinates (2,3). I'd like to be able to annotate it using \node at (2,3) {text};

Best Answer

If you want to refer to the axis coordinates of a pgfplots axis, you'll need to put the TikZ commands (like \draw, \node, or \path) inside the axis environment, and you'll need to use the axis cs: coordinate system.

In your example, you could say

...
\addplot [red, mark=*, mark options={draw=black}, only marks]
coordinates {
(-0.05,0.25) 
};

\node at (axis cs:1,1) [anchor=north east] {test};
\node at (axis cs:0,0) [anchor=south west] {test};
\end{axis}
...

to get

Related Question