# Double legend with twinx()

**URL:** <https://discourse.julialang.org/t/double-legend-with-twinx/19524>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [January 11, 2019, 4:17pm UTC](https://discourse.julialang.org/t/double-legend-with-twinx/19524 "2019-01-11T16:17:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leti93](https://avatars.discourse-cdn.com/v4/letter/l/a9adbd/32.png) [@leti93](https://discourse.julialang.org/u/leti93)\
**Post date:** [January 11, 2019, 4:17pm UTC](https://discourse.julialang.org/t/double-legend-with-twinx/19524/1 "2019-01-11T16:17:22Z")

</div>

I am trying to plot this:

plot(1:10, 1:10, seriestype = :bar, label = “1”, alpha = 0.4, legend = :left )  
plot!(twinx(), 1:10, 501:510, label = “2”)

but I get two different legends and I want to get only one. (I moved the first legend to the left otherwise it is covered by the second one)

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [March 7, 2019, 9:13am UTC](https://discourse.julialang.org/t/double-legend-with-twinx/19524/2 "2019-03-07T09:13:15Z")

</div>

A hack:

```julia
plot(1:10, 1:10, seriestype = :bar, label = "1", alpha = 0.4)
plot!(1:10, NaN.*(1:10), label = "2", linecolor=:green, grid=false, legend=:left) 
plot!(twinx(), 1:10, 501:510, legend=false, linecolor=:green)

```

PS: please quote your code [PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530)

---

<div class="post-metadata">

**Author:** ![leti93](https://avatars.discourse-cdn.com/v4/letter/l/a9adbd/32.png) [@leti93](https://discourse.julialang.org/u/leti93)\
**Post date:** [March 7, 2019, 12:14pm UTC](https://discourse.julialang.org/t/double-legend-with-twinx/19524/3 "2019-03-07T12:14:18Z")

</div>

Thank you!
