Annotation which doesn't depend on the scale?

Is there any way to add annotation (which doesn’t depend on the scale) to plot?
I’ve seen:

plot!(annotation = (0, 1, text(“example”)))

but i want to “stick” annotation for example 15mm from left border, 15 mm from top border even if I change xlim and ylim.

I’m using Plots; gr() backend

I actually just reported a very similar issue yesterday:

I think the main intended usage behind annotations is to annotate data, which is why it’s expressed in data space. I agree it would be useful to be able to express annotation locations in plot space as well.

2 Likes

I see, thank you. My problem could also be solved if I could somehow manually move labels (instead of annotations) to certain position in plot space, but the only arguments I see are :top, :bottom etc…

In PGFPlotsX, you can use the axis coordinate system, eg

using PGFPlotsX
@pgf Axis(Plot({ only_marks }, Table(0:10, 0:10)),
          raw"\node at (rel axis cs:0.3,0.7) {$\sqrt{a^2 + 1}$};")

If you prefer, you can specify things in mm relative to things with a bit of effort (see the the tikz/pgfplots manuals), but relative coordinates in the [0,1]^2 box are generally the most convenient.

3 Likes