# Changing legend of plot after calling plot using Plots.jl

**URL:** <https://discourse.julialang.org/t/changing-legend-of-plot-after-calling-plot-using-plots-jl/26537>\
**Category:** General Usage\
**Created:** [July 19, 2019, 9:25am UTC](https://discourse.julialang.org/t/changing-legend-of-plot-after-calling-plot-using-plots-jl/26537 "2019-07-19T09:25:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gobs](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@gobs](https://discourse.julialang.org/u/gobs)\
**Post date:** [July 19, 2019, 9:25am UTC](https://discourse.julialang.org/t/changing-legend-of-plot-after-calling-plot-using-plots-jl/26537/1 "2019-07-19T09:25:21Z")

</div>

I would like to do something like the following:

```julia
x = 1:10 
y = 2.*x
for p = 1:3
    plot(x,y, lab = "Data")
    p == 1 ? legend(:topright) : legend(false)

```

Except for the life of me I can’t find out how to change the legend after having plotted - it seems you can only do `plot(x, y, legend=false)` but not the above. Is that the case?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 19, 2019, 9:28am UTC](https://discourse.julialang.org/t/changing-legend-of-plot-after-calling-plot-using-plots-jl/26537/2 "2019-07-19T09:28:57Z")

</div>

I believe you need to re-plot

---

<div class="post-metadata">

**Author:** ![Karajan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karajan/32/8545_2.png) [@Karajan](https://discourse.julialang.org/u/Karajan)\
**Post date:** [July 19, 2019, 9:31am UTC](https://discourse.julialang.org/t/changing-legend-of-plot-after-calling-plot-using-plots-jl/26537/3 "2019-07-19T09:31:42Z")

</div>

I think `plot!(legend = false)` should do what you are looking for? `plot!` modifies the current plot instead of creating a new one.

---

<div class="post-metadata">

**Author:** ![gobs](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@gobs](https://discourse.julialang.org/u/gobs)\
**Post date:** [July 23, 2019, 8:19am UTC](https://discourse.julialang.org/t/changing-legend-of-plot-after-calling-plot-using-plots-jl/26537/4 "2019-07-23T08:19:06Z")

</div>

Thank you, that’s exactly what I was looking for!
