I intend to create a figure with a broken Axis, which can be useful when the data range is relatively large but relevant details occur only close to the maximal / minimal values.
For example, let’s say we want to create a figure like this one
We can create the entire figure by drawing the top and bottom half separately, however I cannot figure out how to get the red diagonal lines, which are commonly used to indicate broken axes (in black of course, I used red here for emphasis).
I tried a manual approach using poly!(...)
, but this fails, as poly cannot draw outside of the axis. On the other hand a solution could be to specify the end markers for the spines, for example like many textbook figures have arrow heads. But, afaik, Makie cannot do that?!?
I used the following code to create the above figure, minus the red, diagonal indicator lines:
function makeTestFigure()
fig = Figure(resolution = (150, 150), fontsize = 10)
axisMain = Axis(fig[1, 1],
xlabel = "x Label", ylabel = "y Label",
ytickcolor = :white, yticklabelcolor = :white, ygridvisible = false,
leftspinecolor = :white, rightspinecolor = :white,
bottomspinecolor = :white, topspinecolor = :white
)
xlims!(axisMain, (-1, 6.))
axisLow = Axis(fig[1, 1],
ylabel = "Lorem Ipsum", ylabelcolor = RGBA(1.0, 1.0, 1.0, 1.0),
ylabelpadding = 2.0, yticklabelsize = 8, height = Relative(0.33), valign = 0.0,
topspinecolor = :white, yticks = [0, 1]
)
hidexdecorations!(axisLow)
xlims!(axisLow, (-1., 6.))
ylims!(axisLow, (-0.2,-0.2+1.5))
axisHigh = Axis(fig[1, 1],
ylabel = "Lorem Ipsum", ylabelcolor = RGBA(1.0, 1.0, 1.0, 1.0),
ylabelpadding = 2.0, yticklabelsize = 8, height = Relative(0.55), valign = 1.0,
bottomspinecolor = :white, yticks = [9, 10, 11]
)
hidexdecorations!(axisHigh)
xlims!(axisHigh, (-1, 6.))
ylims!(axisHigh, (8.5, 11.))
boxcar(t) = t > 0. && t < 5. ? 10. : 0.
ts = range(-1.0, 6., length = 101)
for axis ∈ [axisLow, axisHigh]
lines!(axis, ts, boxcar.(ts))
end
fig
end