I’m trying to create a single line graph plotting totally different multiple quantities with more than two y axes. I’m almost successful. See the plot below. One thing that I don’t know how to achieve is to align the y axes at y = 0. That is quite necessary to me.
I know I can specify the limits
for each variable in such a way that y=0 comes at the same place, but that would be too tedious a program to write. . . .
using CairoMakie
xax = 0:(pi/16):pi
co = cos.(xax)
si = sin.(xax) .* 100
ta = tan.(xax) .* 0.001
lims = ((0,3), nothing)
col1 = Makie.wong_colors()[1]
col2 = :gray
col3 = Makie.wong_colors()[2]
fig = Figure()
ax1 = Axis(fig[1,2], limits=lims)
ax2 = Axis(fig[1,2], limits=lims, ylabel="var 2")
ax3 = Axis(fig[1,2], limits=lims)
lines!(ax1, xax, co, color=col1)
lines!(ax2, xax, si, color=col2)
lines!(ax3, xax, ta, color=col3)
linkxaxes!(ax1,ax2,ax3)
hidespines!(ax1, :r, :l, :b, :t)
hidespines!(ax3, :r, :l, :b, :t)
hidedecorations!(ax1)
hidedecorations!(ax3)
ax1_2 = Axis(fig[1,1], ylabel="var 1",
yticklabelcolor = col1,
leftspinecolor = col1,
ytickcolor = col1,
ylabelcolor = col1,
)
ax3_2 = Axis(fig[1,3], ylabel="var 3",
yticklabelcolor = col3,
leftspinecolor = col3,
ytickcolor = col3,
ylabelcolor = col3,
)
linkyaxes!(ax1, ax1_2)
hidexdecorations!(ax1_2)
hideydecorations!(ax1_2, label=false, ticklabels=false, ticks=false)
hidespines!(ax1_2, :r, :b, :t)
linkyaxes!(ax3, ax3_2)
hidexdecorations!(ax3_2)
hideydecorations!(ax3_2, label=false, ticklabels=false, ticks=false)
hidespines!(ax3_2, :r, :b, :t)
colsize!(fig.layout, 1, 15)
colsize!(fig.layout, 3, 15)
save("tmp.png", fig)