# Plot with three y-axes (, so one y-axis has to be double)

**URL:** <https://discourse.julialang.org/t/plot-with-three-y-axes-so-one-y-axis-has-to-be-double/58699>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [April 6, 2021, 4:17pm UTC](https://discourse.julialang.org/t/plot-with-three-y-axes-so-one-y-axis-has-to-be-double/58699 "2021-04-06T16:17:34Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![dadaforpeace](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@dadaforpeace](https://discourse.julialang.org/u/dadaforpeace)\
**Post date:** [November 16, 2021, 5:49pm UTC](https://discourse.julialang.org/t/plot-with-three-y-axes-so-one-y-axis-has-to-be-double/58699/11 "2021-11-16T17:49:07Z")

</div>

I came up with a satisfying solution myself, after finally finding a solution to move the y-axis label here [In Plots.jl, how does one control the space between ylabel and yaxis? - #15 by Andre\_Mello](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/15). The only thing which I could not solve are the position of the legends. Here is the picture:

 ![Population-Energy-PPM](https://global.discourse-cdn.com/julialang/original/3X/c/f/cf3dd9c603407603c32ceaf0ee1108e521d70ba5.png)

And here the corresponding code:

```julia
a=18
plot(df_2.Year,df_2[:,4],
    xlims=(1800,2021),
    label = "Population", 
    ylabel = "World Population",
    color=RGB(0.337, 0.631, 0.749),
    linewidth=3, 
    legend = :topleft, 
    grid = :off,
    size = (1600,800),
    left_margin = 10Plots.mm, 
    right_margin = 50Plots.mm, 
    foreground_color_guide = RGB(0.337, 0.631, 0.749),
    ytickfontcolor = RGB(0.337, 0.631, 0.749),
    xtickfontsize=a,
    ytickfontsize=a,
    xguidefontsize=a,
    yguidefontsize=a,
    legendfontsize=a)
p = twinx()
plot(p,df_3.Year,df_3[:,4],
    xlims=(1800,2021),
    label = "Global CO₂ atmospheric concentration", 
    ylabel = "\n\n\n\n\n"*"Global CO₂ concentration in ppm",
    color =RGB(0.439, 0.368, 0.470),
    linewidth=3, 
    legend = :topright, 
    grid = :off,
    size = (1600, 800),
    left_margin = 10Plots.mm, 
    right_margin = 50Plots.mm, 
    yticks = [280,315,345,380,410],
    foreground_color_guide = RGB(0.439, 0.368, 0.470),
    ytickfontcolor = RGB(0.439, 0.368, 0.470),
    xtickfontsize=a,
    ytickfontsize=a,
    xguidefontsize=a,
    yguidefontsize=a,
    legendfontsize=a)
p = twinx()
plot!(p,df_1.Year,df_1.sum,
    xlims=(1800,2021),
    label = "Energy Consumption", 
    ylabel = "World Primary Energy Consumption",
    color =RGB(0.949, 0.352, 0.219),
    linewidth=3, 
    legend = :left, 
    grid = :off,
    size = (1600, 800),
    left_margin = 10Plots.mm, 
    right_margin = 50Plots.mm, 
    foreground_color_guide = RGB(0.949, 0.352, 0.219),
    ytickfontcolor = RGB(0.949, 0.352, 0.219),
    xtickfontsize=a,
    ytickfontsize=a,
    xguidefontsize=a,
    yguidefontsize=a,
    legendfontsize=a)

```

---

_[View the full topic](https://discourse.julialang.org/t/plot-with-three-y-axes-so-one-y-axis-has-to-be-double/58699)._
