# How to remove the box around the legend in PyPlot.jl

**URL:** <https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528>\
**Category:** Visualization\
**Tags:** pyplot\
**Created:** [June 21, 2019, 3:09pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528 "2019-06-21T15:09:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirtah](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mirtah](https://discourse.julialang.org/u/mirtah)\
**Post date:** [June 21, 2019, 3:09pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528/1 "2019-06-21T15:09:24Z")

</div>

hi.  
I would like to remove the box around the legend in my plot.  
May I ask you to how to do this. Sorry , I am new to Julia.  
this is the code I use.  
version of Julia :1.1.1

![1](https://global.discourse-cdn.com/julialang/original/2X/5/5d4f7131f3400826b8d8898dc83f555280f63fb5.png)

using PyPlot  
x=[1,2,3,4]  
y=x  
figure()  
plot(x,y, label=“y=x”)  
legend()

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [June 21, 2019, 5:46pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528/2 "2019-06-21T17:46:45Z")

</div>

If you’re not tied to PyPlot and are able to try plotting with [Gaston](https://mbaz.github.io/Gaston.jl/v0.10.0/), you can do it with

```julia
x = [1,2,3,4]
plot(x, legend="y=x", keyoptions="top left")

```

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [June 21, 2019, 9:41pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528/3 "2019-06-21T21:41:09Z")

</div>

`legend(frameon=false)`

see the matplotlib manual for more info

---

<div class="post-metadata">

**Author:** ![mirtah](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mirtah](https://discourse.julialang.org/u/mirtah)\
**Post date:** [June 23, 2019, 1:28pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528/4 "2019-06-23T13:28:40Z")

</div>

Thank you very much. I tried your solution, but did not work.  
I used framealpha=0 and removed the box.  
I appreciate all for helping me.  
Best regards

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [June 23, 2019, 3:24pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528/5 "2019-06-23T15:24:18Z")

</div>

Strange. This works on my machine:

```julia
figure()
plot(x,y, label="y=x")
legend(frameon=false)

```

---

<div class="post-metadata">

**Author:** ![Pawan\_Kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pawan_kumar/32/30291_2.png) [@Pawan\_Kumar](https://discourse.julialang.org/u/Pawan_Kumar)\
**Post date:** [October 28, 2021, 2:27pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528/6 "2021-10-28T14:27:34Z")

</div>

unfortunately none of the above worked for me, but this one works fantastic for me.

```julia
 fg_legend = :false

```

Example

```julia
 plot(rand(10,1), legend=:true, label="Label", fg_legend = :false)

```

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [October 28, 2021, 2:56pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528/7 "2021-10-28T14:56:19Z")

</div>

> [@Pawan\_Kumar](#):
>
> ` plot(rand(10,1), legend=:true, label="Label", fg_legend = :false)`

This looks like `Plots.jl` rather than `PyPlot.jl`

---

<div class="post-metadata">

**Author:** ![Pawan\_Kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pawan_kumar/32/30291_2.png) [@Pawan\_Kumar](https://discourse.julialang.org/u/Pawan_Kumar)\
**Post date:** [October 31, 2021, 8:54pm UTC](https://discourse.julialang.org/t/how-to-remove-the-box-around-the-legend-in-pyplot-jl/25528/8 "2021-10-31T20:54:38Z")

</div>

thanks…you are correct
