Created
May 2, 2021 17:30
-
-
Save jkrumbiegel/24c85511c618039d265c774ee2c9d850 to your computer and use it in GitHub Desktop.
cleveland gridlayout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = Figure() | |
nrows, ncols = (3, 7) | |
real_axes = map(Iterators.product(1:nrows, 1:ncols)) do (i, j) | |
ax = Axis(f[2i, j]) | |
if i < nrows | |
hidexdecorations!(ax, grid = false) | |
end | |
if 1 < j < ncols | |
hideydecorations!(ax, grid = false) | |
end | |
if j == 1 | |
if iseven(i) | |
hideydecorations!(ax, grid = false) | |
end | |
end | |
if j == ncols | |
ax.yaxisposition = :right | |
if isodd(i) | |
hideydecorations!(ax, grid = false) | |
end | |
end | |
if i == nrows && isodd(j) | |
hidexdecorations!(ax, grid = false) | |
end | |
ax.topspinevisible = false | |
ax | |
end | |
top_axes = map(1:ncols) do j | |
ax = Axis(f[1, j]) | |
end | |
for (i, ax) in enumerate(top_axes) | |
iseven(i) && hidexdecorations!(ax, ticks = false) | |
ax.xaxisposition = :top | |
hideydecorations!(ax) | |
hidespines!(ax) | |
end | |
for i in 1:nrows, j in 1:ncols | |
Box(f[2i-1, j], color = :orange) | |
Label(f[2i-1, j], "$i, $j", tellwidth = false, padding = (5, 5, 5, 5)) | |
end | |
linkaxes!(real_axes..., top_axes...) | |
colgap!(f.layout, 0) | |
rowgap!(f.layout, 0) | |
for ax in real_axes | |
lines!(ax, cumsum(randn(100))) | |
end | |
f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment