Hello!
I have some data I’d like to plot with a broken axis. Basically there is one data point at the beginning that is way different than the rest.
I found this post about implementing a broken axis. I tried to adapt it in the MWE below but the result is not right.
Any ideas on how to get this to correctly plot?
data = [2.9037750420063544e-14
0.010080615135321012
0.009435526507153675
0.011950631745492903
0.020249366000687767
0.029453566657917533
0.03378641257881644
0.04495876725797948
]
n = length(data)
times = 1:n
begin
fig = Figure()
below_break = (1E-15, 1E-13)
above_break = (1E-4, 1E0)
lims = Observable((below_break, above_break))
gL = GridLayout(fig[1, 1])
ax_top = Axis(gL[1, 1], yscale=log10)
ax_bot = Axis(gL[2, 1], yscale=log10)
on(lims) do (bottom, top)
ylims!(ax_bot, bottom)
ylims!(ax_top, top)
rowsize!(gL, 1, Auto(top[2] - top[1]))
rowsize!(gL, 2, Auto(bottom[2] - bottom[1]))
end
hidexdecorations!(ax_top, grid=false)
ax_top.bottomspinevisible = false
ax_bot.topspinevisible = false
linkxaxes!(ax_top, ax_bot)
rowgap!(gL, 10)
angle = pi / 8
linelength = 30
segments = lift(
@lift($(ax_top.yaxis.attributes.endpoints)[1]),
@lift($(ax_bot.yaxis.attributes.endpoints)[2]),
@lift($(ax_top.elements[:yoppositeline][1])[1]),
@lift($(ax_bot.elements[:yoppositeline][1])[2]),
) do p1, p2, p3, p4
ps = Point2f[p1, p2, p3, p4]
map(ps) do p
a = p + Point2f(cos(angle), sin(angle)) * 0.5 * linelength
b = p - Point2f(cos(angle), sin(angle)) * 0.5 * linelength
(a, b)
end
end
linesegments!(fig.scene, segments, color=:black)
scatterlines!(ax_bot, times, data)
scatterlines!(ax_top, times, data)
notify(lims)
fig
end