# Annotation to figure with 2 Subplots

**URL:** <https://discourse.julialang.org/t/annotation-to-figure-with-2-subplots/59734>\
**Category:** Visualization\
**Tags:** plotting\
**Created:** [April 21, 2021, 1:08pm UTC](https://discourse.julialang.org/t/annotation-to-figure-with-2-subplots/59734 "2021-04-21T13:08:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hardy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@hardy](https://discourse.julialang.org/u/hardy)\
**Post date:** [April 21, 2021, 1:08pm UTC](https://discourse.julialang.org/t/annotation-to-figure-with-2-subplots/59734/1 "2021-04-21T13:08:46Z")

</div>

Hello,  
I try to make a Plot with 2 Subplots and use the gr() backend. The first (p1) is a 3D surface plot and the 2. (p2) a 2D contour plot. The axis of both subplots are also different. I tried to put the annotation in the second subplot but it didn’t appear and I get the error “z is not defined” (p2 is 2D).  
I think I have to do

p3= plot(p1,p2, layout = grid(2, 1,heights=[0.6 ,0.4]), annotate(???))

But I can’t get it to work. Which coordinates should I take, the data coordinates from p1 or p2? Or can I do something like bottom\_right for the whole figure? I searched the doc but didn’t find the Answer.

Any help is highly appreciated

---

<div class="post-metadata">

**Author:** ![hardy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@hardy](https://discourse.julialang.org/u/hardy)\
**Post date:** [April 21, 2021, 5:49pm UTC](https://discourse.julialang.org/t/annotation-to-figure-with-2-subplots/59734/2 "2021-04-21T17:49:56Z")

</div>

I changed it a little bit and added the annotation directly to plot 2 (not afterward with annotate!)

function plotgraph(Kp\_col, Ki\_col)

```
loss = find_loss(Kp_col, Ki_col)

p1 = plot(Kp_col, Ki_col, loss, st=:surface, c= cgrad(:viridis,rev=true), camera=(70,25),
    xlabel="Kp", ylabel="Ki", zlabel="Loss", xrotation=45,right_margin = 8.52Plots.mm) #,yrotation=45)
p2 = contour(Ki_col, Kp_col, loss', c= cgrad(:viridis,rev=true), xlabel="Ki", 
     ylabel="Kp", xlims=(10,74), annotations=(75, 3690, Plots.text("Loss", 8, :left))) #, legend = :none)
p3= plot(p1,p2, layout = grid(2, 1,heights=[0.6 ,0.4]))

return p3

```

end

Now I don’t get the error “z not defined” but a warning:  
┌ Warning: Unused font arg: Plots.PlotText(“Loss”, Plots.Font(“sans-serif”, 8, :left, :vcenter, 0.0, RGB{N0f8}(0.0,0.0,0.0))) (Plots.PlotText)  
└ @ Plots ~/.julia/packages/Plots/SjqWU/src/components.jl:286

No idea what to do anymore. Can Anybody help?

---

<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 21, 2021, 9:29pm UTC](https://discourse.julialang.org/t/annotation-to-figure-with-2-subplots/59734/3 "2021-04-21T21:29:48Z")

</div>

@hardy, please read the [guidelines here](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) and post a MWE. Thank you.

---

<div class="post-metadata">

**Author:** ![hardy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@hardy](https://discourse.julialang.org/u/hardy)\
**Post date:** [April 22, 2021, 1:18pm UTC](https://discourse.julialang.org/t/annotation-to-figure-with-2-subplots/59734/4 "2021-04-22T13:18:20Z")

</div>

I’m really embarrassed now, but I just forgot a zero in a number (one of the coordinates). So my annotation was out of sight. I checked the code over and over but didn’t notice it.  
Sorry for wasting your time.
