Skip to content

Instantly share code, notes, and snippets.

@jkrumbiegel
Created March 27, 2025 13:18
Show Gist options
  • Save jkrumbiegel/830e980bc0c67cc06e617db2918e19dc to your computer and use it in GitHub Desktop.
Save jkrumbiegel/830e980bc0c67cc06e617db2918e19dc to your computer and use it in GitHub Desktop.
Stacked twin axis Makie
f = Figure()
main_ax = Axis(f[1, 1])
twin_ax_layout = GridLayout(f[1, 1, Right()])
twin_axis_pairs = map(1:3) do i
data_axis = Axis(f[1, 1])
label_axis = Axis(twin_ax_layout[1, i], width = 0, alignmode = Outside(), yaxisposition = :right)
hidedecorations!(data_axis)
hidespines!(data_axis)
hidexdecorations!(label_axis)
linkyaxes!(data_axis, label_axis)
linkxaxes!(main_ax, data_axis)
return data_axis, label_axis
end
for ((dax, lax), color) in zip(twin_axis_pairs, [:red, :green, :blue])
lines!(dax, cumsum(randn(100)); color)
lax.yticklabelcolor = color
lax.ytickcolor = color
lax.rightspinecolor = color
lax.leftspinecolor = color
end
f
@jkrumbiegel
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment