# Annotations disappear when put on modified plot

**URL:** <https://discourse.julialang.org/t/annotations-disappear-when-put-on-modified-plot/97394>\
**Category:** General Usage\
**Tags:** question, plotting\
**Created:** [April 12, 2023, 1:59pm UTC](https://discourse.julialang.org/t/annotations-disappear-when-put-on-modified-plot/97394 "2023-04-12T13:59:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Woodmouth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/woodmouth/32/24394_2.png) [@Woodmouth](https://discourse.julialang.org/u/Woodmouth)\
**Post date:** [April 12, 2023, 1:59pm UTC](https://discourse.julialang.org/t/annotations-disappear-when-put-on-modified-plot/97394/1 "2023-04-12T13:59:49Z")

</div>

[This disscusion](https://discourse.julialang.org/t/plots-using-multiple-colours-in-title/69870/9) presents a way to use annotations to create a multi-colored title, but I have some issues creating annotations on plots that have been modified. Here is a minimal reproducible example using Julia 1.7.2.

```julia
using Plots
#gr() # The same issue is also present in the gr backend
pyplot()

function make_plot(X, Y, add_plot=true)

    p = plot()
    if add_plot
        plot!([1,2],[1,2])
    end
    tc = [:red, :black, :orange]
    for (i,s) in enumerate(["text", "with", "color"])
        annotate!(0.25*i , 0.5, text(s, tc[i], 18))
    end
    return p
end

plot1 = make_plot([1], [1], true)
plot2 = make_plot([1], [1], false)
plot(plot1, plot2)

```

![Untitled](https://global.discourse-cdn.com/julialang/original/3X/1/0/1039ef4075677dd401ea7072b26d45751e93331d.png)

I would have expected the text to appear on top of the line, but instead it is nowhere. Any suggestions?

(PS: If anyone knows a better way to create a multi-colored title using pyplot btw, that would also be welcome.)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 12, 2023, 2:09pm UTC](https://discourse.julialang.org/t/annotations-disappear-when-put-on-modified-plot/97394/2 "2023-04-12T14:09:19Z")

</div>

There is a problem with the X, Y coordinates in `annotate!()`.  
You can add the boolean variable `add_plot` to adjust these in both cases:

```julia
annotate!(add_plot + 0.25*i , add_plot + 0.5, text(s, tc[i], 18))

```

---

<div class="post-metadata">

**Author:** ![Woodmouth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/woodmouth/32/24394_2.png) [@Woodmouth](https://discourse.julialang.org/u/Woodmouth)\
**Post date:** [April 14, 2023, 1:51pm UTC](https://discourse.julialang.org/t/annotations-disappear-when-put-on-modified-plot/97394/3 "2023-04-14T13:51:28Z")

</div>

Thanks! I did try various coordinates in my real plot, but I didn’t know if that was the problem or if there was something else going on, so I had given up. I found them when I tried again now though, so thanks. 🙂
