Hey everybody,
For the last months Simon and I have been working on streamlining the integration of MakieLayout in the Makie ecosystem. Now, with AbstractPlotting.jl v0.15, we finally have made some bigger changes to our default plotting pipeline to make the features of MakieLayout more easily accessible and reduce boilerplate by a lot.
The biggest change is that where you had to write this before to use MakieLayout’s more powerful axis:
scene, layout = layoutscene()
ax = layout[1, 1] = LAxis(scene)
scatter!(ax, randn(100, 2))
scene
you can now just write this, as MakieLayout’s axis is the default now
scatter(randn(100, 2))
We’ve introduced a Figure
object which bundles more of the functionality which was scattered around layoutscene
and other helper functions. You can actually directly plot into nested positions in a figure, so the need to manually create GridLayouts is reduced. For example, you could create a subplot in a nested gridlayout with the command scatter(fig[1, 2][1, 1:2], randn(100, 2))
. This would mean first row, second column, then in the nested grid first row, first to second column. You don’t have to create any intermediate gridlayouts yourself.
Also, we’ve renamed almost all of the LObjects and cleaned up some older cruft. LAxis => Axis, LButton => Button, LSlider => Slider, etc.
There’s still a lot to do, so we appreciate it if you check out the new features and let us know if you find any bugs! You only need to install one of the backends CairoMakie, GLMakie or WGLMakie, everything you need is imported with those. (Makie.jl is just an old GLMakie bundle by now and will probably be replaced soon)
Before you go and try it, here’s a quick demo figure where you can check out some of the new syntax. I did this static example with CairoMakie, but check out GLMakie and WGLMakie for interactivity if you haven’t, yet:
using CairoMakie
using AbstractPlotting.ColorSchemes
function demo()
xs = LinRange(0.5, 6, 50)
ys = LinRange(0.5, 6, 50)
data1 = [sin(x^1.5) * cos(y^0.5) for x in xs, y in ys] .+ 0.1 .* randn.()
data2 = [sin(x^0.8) * cos(y^1.5) for x in xs, y in ys] .+ 0.1 .* randn.()
f = Figure(resolution = (1400, 1100), font = "Avenir Light")
ax, co = contourf(f[1, 1][1, 1], xs, ys, data1, levels = 6,
axis = (title = "Pyramidal Cells", ylabel = "Coronal Section"))
contour!(xs, ys, data1, color = :black)
contourf(f[1, 1][1, 2], xs, ys, data2, levels = 6, axis = (title = "Layer IV Neurons",))
contour!(xs, ys, data2, color = :black)
hidedecorations!.([ax, current_axis()])
ax.ylabelvisible = true
f[1, 1][1, 1:2, Bottom()] = Label(f, "Sagittal Section", padding = (0, 0, 0, 10))
f[1, 1][2, 1:2] = Colorbar(f, height = 20, vertical = false, label = "Spike Rate",
flipaxisposition = false, ticklabelalign = (:center, :top))
_, sc1 = scatter(f[1, 2][1, 1], randn(100, 2) * [1 5; 3 1],
color = :red, colorrange = (1, 10),
axis = (title = "Particle Simulation", xlabel = "Velocity [m/s]",
ylabel = "Acceleration [m/s²]"))
sc2 = scatter!(randn(100, 2) * [0.5 -5; 1 0.1],
color = :blue, colorrange = (1, 10), marker = 'x')
f[1, 2][1, 2] = Legend(f, [sc1, sc2], ["Gamma", "Beta"], "Particles", framevisible = false)
f[2, :] = Box(f, color = :gray90)
f[2, :] = Label(f, "Group Measurements", padding = (0, 0, 5, 5))
for group in 1:3
f[3, :][1, group, Top()] = Box(f, color = :gray90)
f[3, :][1, group, Top()] = Label(f, "Group $group", padding = (0, 0, 5, 5))
for i in 1:3, j in 1:3
f[3, :][1, group][i, j] = Axis(f, xticks = LinearTicks(4))
i < 3 && hidexdecorations!(current_axis(), grid = false)
j > 1 && hideydecorations!(current_axis(), grid = false)
for n in 1:3
lines!(0..10, cumsum(randn(1000)), color = ColorSchemes.Set1_4[n])
end
end
end
f[0, :] = Label(f, "Makie Complex Plot Demo", textsize = 30)
f
end