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

I have the same problem but unfortunately GLMakie did not work for me. The data in addition to the Jupyter Notebook file can be found here: https://datashare.mpcdf.mpg.de/s/uPOltmpkDjlZl4F

I am doing the following:

using Plots
using CSV
using DataFrames
using Colors

df_1 = DataFrame(CSV.File("Energy.csv"))
df_2 = DataFrame(CSV.File("Population.csv"))
df_3 = DataFrame(CSV.File("Ppm.csv"))

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, 
    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 = "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, 
    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, 
    xtickfontsize=a,
    ytickfontsize=a,
    xguidefontsize=a,
    yguidefontsize=a,
    legendfontsize=a)

The result is the following:

What I would like to change:

  • Move the Y-ticks + Y-label of ‘Energy’ to the right
  • Color the Y-ticks + Y-label of each graph
  • Put all legends to the :topleft in decending size order.

Please help me to make the plot pretty again