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

**URL:** <https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290>\
**Category:** Visualization\
**Tags:** plots, pgfplotsx\
**Created:** [May 31, 2018, 2:13pm UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290 "2018-05-31T14:13:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_van\_Weelderen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rob_van_weelderen/32/7621_2.png) [@Rob\_van\_Weelderen](https://discourse.julialang.org/u/Rob_van_Weelderen)\
**Post date:** [May 31, 2018, 2:13pm UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/1 "2018-05-31T14:13:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [May 31, 2018, 2:46pm UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/2 "2018-05-31T14:46:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Rob\_van\_Weelderen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rob_van_weelderen/32/7621_2.png) [@Rob\_van\_Weelderen](https://discourse.julialang.org/u/Rob_van_Weelderen)\
**Post date:** [May 31, 2018, 8:42pm UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/3 "2018-05-31T20:42:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [May 31, 2018, 9:14pm UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/4 "2018-05-31T21:14:37Z")

</div>

It should all be here [http://docs.juliaplots.org/latest/examples/pgfplots/#annotations](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.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 22, 2021, 11:17am UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/5 "2021-11-22T11:17:11Z")

</div>

Here’s a more recent version of the link that is not actually dead [https://docs.juliaplots.org/latest/generated/pgfplotsx/#pgfplotsx-ref20](https://docs.juliaplots.org/latest/generated/pgfplotsx/#pgfplotsx-ref20) 🙂

---

<div class="post-metadata">

**Author:** ![st1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/st1/32/26929_2.png) [@st1](https://discourse.julialang.org/u/st1)\
**Post date:** [November 15, 2022, 6:15pm UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/7 "2022-11-15T18:15:16Z")

</div>

Your link is already dead again… current version seems to be here: [Using LaTeX code · PGFPlotsX.jl](https://kristofferc.github.io/PGFPlotsX.jl/stable/examples/latex/#Annotating-plots)

---

<div class="post-metadata">

**Author:** ![mgkuzyk](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@mgkuzyk](https://discourse.julialang.org/u/mgkuzyk)\
**Post date:** [September 29, 2023, 10:37pm UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/8 "2023-09-29T22:37:12Z")

</div>

Is it possible to place an annotation at position (x,y) on a plot as described above but to also have the value of a variable displayed? I have in mind something like “Position =” z. Here the value of the variable z would be placed after the text.

---

<div class="post-metadata">

**Author:** ![MichaelGao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michaelgao/32/27370_2.png) [@MichaelGao](https://discourse.julialang.org/u/MichaelGao)\
**Post date:** [December 4, 2023, 9:25am UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/9 "2023-12-04T09:25:45Z")

</div>

You can achieve this by using `$` in a string to specify the value of your variables.  
For example:  
`annotate!(x, y, Plots.text("$x, $y", :red, :right, 10))`

---

<div class="post-metadata">

**Author:** ![alex-s-gardner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alex-s-gardner/32/30210_2.png) [@alex-s-gardner](https://discourse.julialang.org/u/alex-s-gardner)\
**Post date:** [August 30, 2024, 5:46pm UTC](https://discourse.julialang.org/t/plots-jl-positioning-and-scaling-of-annotate/11290/10 "2024-08-30T17:46:03Z")

</div>

updated link to Plots annotate! documentation example: [Annotations · Plots](https://docs.juliaplots.org/stable/gallery/plotlyjs/generated/plotlyjs-ref020/)
