Plots.jl : positioning and scaling of "annotate!"


#1

I would like to put on the lower right corner of my plots a notification text string, typically citing the the “data source : date of production”

Although I can put text using

annotate!(xpos, ypos, "my text", :color)

it is presently missing some needed options for which I didn’t manage to find a solution either going through the Plots.jl documentation or searching discourse.

What I’m looking for is:

  • how to change the font used (presently by default it’s way too big)
  • how to make it right aligned.

N.B. all this is possible by using PyPlot directly, but I want to move away from that to a more Julian-like and consistent way of doing.

I’d appreciate some help.
All the best,
Rob


#2

annotate!(xpos, ypos, text("mytext", :red, :right, 3))
The text constructor is “magic” so the order of the various arguments isn’t important.


#3

Thanks Mike,

  • with the gr() backend that does the trick! THANKS.

  • however when using the pgfsplots() backend (which is the one I usually employ), one cannot annotate below the x-axis, nor change the font-size

Can I bother you for how to change the font to “Courier”, “Sans” for instance (again I do not manage to extract this from the docs, nor ? or methods(text) get me any furher)?

Best,
Rob.


#4

It should all be here http://docs.juliaplots.org/latest/examples/pgfplots/#annotations
The example actually uses courier.

One thing to consider if you’re using pgfplots because you’re embedding in LaTeX. Consider savefig("myfigure.tex"), the resulting figure should take fonts and stuff from the latex document.