If you have used Makie.jl before, you will know that the interactivity with Observables and the GPU-powered plotting is great, but the layouting capabilities are limited and 2D axes suffer from problems like arbitrary font sizes. This package is an extension of Makie insofar that it adds its own 2D axis type that can be used together with a grid-based layout.
You can iteratively expand layouts, link axes, add super and side titles easily, and many more things. Decorations are given in pixel sizes so they all look the same. There are many small features and tweaks to allow you to create the best aligned layout that uses the available space efficiently while looking good.
The package is still in its early stages but is now registered and can be installed via the usual ] add MakieLayout.
It appears that I cannot create a layout with a single column. I tried the example in the README, only changing ncols = 1 instead of ncols = 2 and got the following error:
MethodError: no method matching zero(::Type{Any})
Closest candidates are:
zero(::Type{Union{Missing, T}}) where T at missing.jl:87
zero(!Matched::Type{LibGit2.GitHash}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.1/LibGit2/src/oid.jl:220
zero(!Matched::Type{Pkg.Resolve.VersionWeights.VersionWeight}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.1/Pkg/src/resolve/VersionWeights.jl:19
...
Stacktrace:
[1] zero(::Type{Any}) at ./missing.jl:87
[2] reduce_empty(::typeof(+), ::Type) at ./reduce.jl:227
[3] reduce_empty(::typeof(Base.add_sum), ::Type) at ./reduce.jl:234
[4] mapreduce_empty(::typeof(identity), ::Function, ::Type) at ./reduce.jl:251
[5] _mapreduce(::typeof(identity), ::typeof(Base.add_sum), ::IndexLinear, ::Array{Any,1}) at ./reduce.jl:305
[6] _mapreduce_dim at ./reducedim.jl:308 [inlined]
[7] #mapreduce#548 at ./reducedim.jl:304 [inlined]
[8] mapreduce at ./reducedim.jl:304 [inlined]
[9] _sum at ./reducedim.jl:653 [inlined]
[10] _sum at ./reducedim.jl:652 [inlined]
[11] #sum#550 at ./reducedim.jl:648 [inlined]
[12] sum(::Array{Any,1}) at ./reducedim.jl:648
[13] solve(::GridLayout, ::GeometryTypes.HyperRectangle{2,Float32}) at /Volumes/Users/grogee/.julia/packages/MakieLayout/07lWR/src/layout_engine.jl:252
[14] (::getfield(MakieLayout, Symbol("##4#6")))(::Bool) at /Volumes/Users/grogee/.julia/packages/MakieLayout/07lWR/src/types.jl:131
[15] #setindex!#1(::getfield(Observables, Symbol("##2#4")), ::Function, ::Observables.Observable{Bool}, ::Bool) at /Volumes/Users/grogee/.julia/packages/Observables/qCJWB/src/Observables.jl:87
[16] setindex! at /Volumes/Users/grogee/.julia/packages/Observables/qCJWB/src/Observables.jl:83 [inlined]
[17] connectchildlayout!(::GridLayout, ::MakieLayout.SpannedLayout{ProtrusionLayout{LayoutedAxis}}) at /Volumes/Users/grogee/.julia/packages/MakieLayout/07lWR/src/layout_engine.jl:668
[18] add_layout! at /Volumes/Users/grogee/.julia/packages/MakieLayout/07lWR/src/layout_engine.jl:644 [inlined]
[19] setindex!(::GridLayout, ::LayoutedAxis, ::Int64, ::Int64) at /Volumes/Users/grogee/.julia/packages/MakieLayout/07lWR/src/layout_engine.jl:636
[20] (::getfield(Main, Symbol("##49#50")))(::Tuple{Int64,Int64}) at ./none:0
[21] iterate at ./generator.jl:47 [inlined]
[22] collect(::Base.Generator{Base.Iterators.ProductIterator{Tuple{UnitRange{Int64},UnitRange{Int64}}},getfield(Main, Symbol("##49#50"))}) at ./array.jl:606
[23] top-level scope at In[21]:12
Could you post the full code? I can’t reproduce this here Although this error has often appeared while I was writing the package, because with one column there are no gaps to sum over… Maybe you also need to update the package again first
for me one column looks like this, which might look weird but is intended behavior, because an auto width column resizes to fixed width single-span content if it finds any. in this case you would have to set the column width to Relative(1)
I’ve pushed my latest changes and tagged a new version, so in a bit you can install that. Let me know if the error persists. I don’t have automated tests yet as Makie doesn’t work on travis, so my tests are of a manual nature so far and are likely to miss bugs.
hmm then I assume it’s because of your Julia version, I’m on 1.3. Could be that some bug with reducing an empty collection was fixed in between? I’ll investigate a bit
can you check with the current master, not the last tagged version? I’ve just pushed a commit where I’ve taken out the sums over empty vectors, even though for some reason they don’t cause problems for me
I just wanted to share my appreciation for this package. To me, this really makes Makie an excellent candidate for producing publication quality plots : )
yes, the axes from standard Makie are more like a part of the plot itself. In MakieLayout, they “contain” the plots and therefore don’t move when panning and zooming
Is there already an example of how to transform an axis-is-data plot into an axis-is-no-data plot? I guess that’s one of the most wanted features Thus, an example is at least a good showcase.
How to place titles above each plot? title(las[i,j], "A nice title") doesn’t seem to work.
Especially, is there a keyword argument, that I can supply to the heatmap?
Point 1: You don’t have to do anything but plot into the new axis instead of the old scene. So scatter!(scene, xy) becomes scatter!(newaxis, xy). The new axis is at its core just a subscene with orthographic projection (plus bells and whistles), so it mostly works the same as the old one in terms of plotting.
Point 2: All (or most anyway) attributes of the axis and the other widgets are in obj.attributes, but getproperty is overloaded for them to access attributes with simple dot notation if they exists. So the title would be either a kwarg when creating the axis like LAxis(scene, title = "A nice title") or you set it after the fact with ax.title = "A nice title. There might be some attributes inaccessible this way right now because there are so many possibilities, it’s easy for me to miss some.
Point 3: I don’t think there’s any threading in Makie right now, MakieLayout is a layer on top so it could never just introduce its own threading. Makie is older than the new threading, so there would need to be a lot of changes I think, but @sdanisch might be on it, I don’t know.