# Plots annotate

**URL:** <https://discourse.julialang.org/t/plots-annotate/37784>\
**Category:** Visualization\
**Created:** [April 17, 2020, 8:48pm UTC](https://discourse.julialang.org/t/plots-annotate/37784 "2020-04-17T20:48:59Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![j2b2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j2b2/32/3387_2.png) [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Post date:** [April 17, 2020, 8:49pm UTC](https://discourse.julialang.org/t/plots-annotate/37784/1 "2020-04-17T20:49:00Z")

</div>

With recent version of Plots (1.0.11) and GR backend:

```julia
annotate!(x,y,t)

```

doesn’t work anymore, I must use:

```julia
annotate!((x,y,t))

```

---

<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:** [April 17, 2020, 9:04pm UTC](https://discourse.julialang.org/t/plots-annotate/37784/2 "2020-04-17T21:04:02Z")

</div>

If you find a bug you should open a github issue on the relevant repository

---

<div class="post-metadata">

**Author:** ![j2b2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j2b2/32/3387_2.png) [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Post date:** [April 18, 2020, 9:55am UTC](https://discourse.julialang.org/t/plots-annotate/37784/3 "2020-04-18T09:55:34Z")

</div>

“The relevant repository”, that is the question ! I never posted github issues, I am afraid we will waste more time if I try it personally, I apologize.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [April 18, 2020, 10:12am UTC](https://discourse.julialang.org/t/plots-annotate/37784/4 "2020-04-18T10:12:19Z")

</div>

This (collaboration, giving and taking) is the base of open source, from which you seem to benefit.  
I understand that not everybody wants to or is able to give something back, but I can assure you, opening a github issue (relevant repository can be at a first step: [https://github.com/JuliaPlots/Plots.jl](https://github.com/JuliaPlots/Plots.jl)) can be done fast and easily. Doing it assures, that the bug you found is not lost until someone else is stumbling over it (and opens an issue), which I am sure will take much more time.  
Just think if Julia has saved you time already (or even gave you a good time) and if this is the case you may rethink your position. Thank you.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [April 18, 2020, 11:26am UTC](https://discourse.julialang.org/t/plots-annotate/37784/5 "2020-04-18T11:26:56Z")

</div>

Quote from the docs [http://docs.juliaplots.org/latest/generated/gr/#gr-ref20-1](http://docs.juliaplots.org/latest/generated/gr/#gr-ref20-1) :

> The `annotations` keyword is used for text annotations in data-coordinates. Pass in a  
> tuple (x,y,text) or a vector of annotations.

So for me, this is not a bug, but a bug fix, but I can’t find out if the docs have changed.

---

<div class="post-metadata">

**Author:** ![j2b2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j2b2/32/3387_2.png) [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Post date:** [April 18, 2020, 12:17pm UTC](https://discourse.julialang.org/t/plots-annotate/37784/6 "2020-04-18T12:17:32Z")

</div>

You’re right, but the simple form `annotate!(x,y,text)` worked until recently (and arguments of any function are, by definition, a `tuple`). Here is a part of the error message that I get now, with explicit reference to a shorthand notation:

```julia
MethodError: no method matching process_annotation(::Plots.Subplot{Plots.GRBackend}, ::Float64)
[...]
#annotate!#421 at shorthands.jl:441 [inlined]
annotate!(::Float64, ::Float64, ::String) at shorthands.jl:441

```

---

<div class="post-metadata">

**Author:** ![j2b2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j2b2/32/3387_2.png) [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Post date:** [April 18, 2020, 12:48pm UTC](https://discourse.julialang.org/t/plots-annotate/37784/7 "2020-04-18T12:48:02Z")

</div>

`annotate!(x,y,text)` works with Plots@1.0.2, but no more with Plots@1.0.4. Github documentation of versions 1.0.3 and 1.0.4 says that annotations were fixed, but I don’t understand the corresponding issues.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [April 18, 2020, 1:02pm UTC](https://discourse.julialang.org/t/plots-annotate/37784/8 "2020-04-18T13:02:17Z")

</div>

Checking the code in shorthands.jl

> <https://github.com/JuliaPlots/Plots.jl/commit/87b220e7473387626c44b044db55ecb410a0047d#diff-03618b0d09cd4796b7d3d3ec1fa91552>

show whats happening.

Before:

```julia
annotate!(anns...; kw...) = plot!(; annotation = anns, kw...)

```

After:

```julia
annotate!(anns...; kw...) = plot!(; annotation = collect(anns), kw...)

```

Now the problem is, that `collect` returns an `Array{AbstractArray{T,1} where T,1}` and this is not accepted by `plot!( ...; annotation(s?) = ...)`  
(I believe it’s a bit more complicated, but I didn’t dig deeper)

A possible fix would be:

```julia
annotate!(anns...; kw...) = plot!(; annotations = (collect.(anns)), kw...)

```

(I don’t know why it is `annotation` and not `annotations` as it should be, just as a side node).

So, this analysis took a bit (of my and your) time. How about opening an issue at [Issues · JuliaPlots/Plots.jl · GitHub](https://github.com/JuliaPlots/Plots.jl/issues) ?

It’s now just your initial use case with a link to this discussion and maybe creating an account at github.

> I am afraid we will waste more time if I try it personally

I am sure this time is not wasted!

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [April 18, 2020, 1:18pm UTC](https://discourse.julialang.org/t/plots-annotate/37784/9 "2020-04-18T13:18:18Z")

</div>

This issue is also related to this:  
[https://github.com/JuliaPlots/Plots.jl/issues/2487](https://github.com/JuliaPlots/Plots.jl/issues/2487)

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [April 19, 2020, 8:24pm UTC](https://discourse.julialang.org/t/plots-annotate/37784/10 "2020-04-19T20:24:01Z")

</div>

Opened an issue:  
[https://github.com/JuliaPlots/Plots.jl/issues/2601](https://github.com/JuliaPlots/Plots.jl/issues/2601)

---

<div class="post-metadata">

**Author:** ![j2b2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j2b2/32/3387_2.png) [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Post date:** [April 20, 2020, 9:24am UTC](https://discourse.julialang.org/t/plots-annotate/37784/11 "2020-04-20T09:24:06Z")

</div>

Oh sorry, you persuaded me to open an issue (#2595), but I didn’t signal it here, and #2595 was quickly closed by a developer and replaced by _pull request_ #2597.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [April 20, 2020, 10:49am UTC](https://discourse.julialang.org/t/plots-annotate/37784/12 "2020-04-20T10:49:20Z")

</div>

Well done! 😆
