# Two y-axis overlaps in pyplot

**URL:** https://discourse.julialang.org/t/two-y-axis-overlaps-in-pyplot/63540
**Category:** General Usage
**Created:** [June 25, 2021, 10:35am UTC](https://discourse.julialang.org/t/two-y-axis-overlaps-in-pyplot/63540 "2021-06-25T10:35:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)
#### Post date: [June 25, 2021, 10:35am UTC](https://discourse.julialang.org/t/two-y-axis-overlaps-in-pyplot/63540/1 "2021-06-25T10:35:08Z")

</div>

I expect to have two y-axis one on the left and another on the right. but it shows overlapped y-axis on the left.

```julia
@show backend()
x = 1:10
y1 = log.(x)
y2 = y1 + 0.05*randn(10)
plot(x, y1, xlabel="x", ylabel="log(x)", title = "\$log(x)\$ vs. x", label=L"log(x)")
scatter!(x,y2, label="\$log(x)\$ + noise")
p = twinx()
plot!(p, x, log10.(x))

```

![image](https://global.discourse-cdn.com/julialang/original/3X/d/e/ded9b78e4d920ce745f1617c731e8984418318a7.png)

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [June 25, 2021, 11:34am UTC](https://discourse.julialang.org/t/two-y-axis-overlaps-in-pyplot/63540/2 "2021-06-25T11:34:24Z")

</div>

I can’t confirm:

```julia
using Plots
using LaTeXStrings

pyplot()
@show backend()

x = 1:10
y1 = log.(x)
y2 = y1 + 0.05*randn(10)
plot(x, y1, xlabel="x", ylabel="log(x)", title = "\$log(x)\$ vs. x", label=L"log(x)")
scatter!(x,y2, label="\$log(x)\$ + noise")
p = twinx()
plot!(p, x, log10.(x))

```

![image](https://global.discourse-cdn.com/julialang/original/3X/a/0/a005148f5777aff542daf131d2ca1f599239e168.png)

Perhaps it’s a version problem?

```julia
julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: AMD Ryzen 9 3900X 12-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, znver2)

(@v1.6) pkg> st
      Status `C:\Users\Oli\.julia\environments\v1.6\Project.toml`
...
  [4c0ca9eb] Gtk v1.1.7
...
  [b964fa9f] LaTeXStrings v1.2.1
...
  [91a5bcdd] Plots v1.15.2
...
  [d330b81b] PyPlot v2.9.0

```

---

<div class="post-metadata">

### Author: ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)
#### Post date: [June 25, 2021, 11:46am UTC](https://discourse.julialang.org/t/two-y-axis-overlaps-in-pyplot/63540/3 "2021-06-25T11:46:29Z")

</div>

HI Oheil, I checked again and found the case is that i set  
` default(grid=:off, box=:on)`  
without this setting it appeared normal.

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [June 25, 2021, 12:40pm UTC](https://discourse.julialang.org/t/two-y-axis-overlaps-in-pyplot/63540/4 "2021-06-25T12:40:13Z")

</div>

Yes, confirmed. It’s the `box=:on` setting and it doesn’t happen with GR backend, so it seems to be a `pyplot` specific problem. Still it’s unclear if this is Julia specific or already in pythons matplotlib.

Perhaps you or someone else can check this and open an appropriate issue for this bug.

---

<div class="post-metadata">

### Author: ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)
#### Post date: [June 25, 2021, 1:13pm UTC](https://discourse.julialang.org/t/two-y-axis-overlaps-in-pyplot/63540/5 "2021-06-25T13:13:33Z")

</div>

Truely GR doesn’t have this problem. Problem for GR is that the Latex string is not rendered sometimes. in this example, the L"xx" string is rendered, but the title, “$ xxx$” is not rendered.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/1/c1f16dadcc90467e9c962f0e1f7d5c41d386df82.png)
