# \[ANN\] MakieLayout.jl: A layout manager for Makie.jl

**URL:** <https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218>\
**Category:** Package Announcements\
**Created:** [November 18, 2019, 11:22am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218 "2019-11-18T11:22:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 18, 2019, 11:22am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/1 "2019-11-18T11:22:31Z")

</div>

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`.

Check out the documentation at [MakieLayout.jl Tutorial · MakieLayout.jl](https://jkrumbiegel.github.io/MakieLayout.jl/dev/), but to start with here are some examples:

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/b/5/b5e5e3145662c2568d7fe8fc1c806ba0454c1a48.png)

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/1/4/14027848f003185742bdfe725f653c34d2baf58c.png)

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/e/4/e470f0cf3c3a2eb8d1c4244748447284b5bf71cd.png)

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/2/e/2e6fedd8b6dec42aa56cb766870103b3953e1f42.png)

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/8/9/898116733d6154102037237e196ede90def58d7a.png)

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [November 19, 2019, 3:02am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/2 "2019-11-19T03:02:34Z")

</div>

This looks fantastic! I’ve been waiting a while for this, and I can’t while to play with it. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [November 21, 2019, 8:43am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/3 "2019-11-21T08:43:18Z")

</div>

It appears that I cannot create a layout with a single column. I tried the example in the [README](https://github.com/jkrumbiegel/MakieLayout.jl/blob/master/README.md), only changing ncols = 1 instead of ncols = 2 and got the following error:

```nohighlight
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

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 21, 2019, 8:51am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/4 "2019-11-21T08:51:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 21, 2019, 8:53am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/5 "2019-11-21T08:53:56Z")

</div>

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)

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/f/2/f23412da92db89c79f18d6d8712ed67d6a9999f7.png)

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [November 21, 2019, 8:54am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/6 "2019-11-21T08:54:08Z")

</div>

Sure, this is the the code I tried. This was right after updating MakieLayout (] up MakieLayout ) to v0.1.2 (Master) an hour or so ago.

```nohighlight
using Makie, MakieLayout
scene = Scene(resolution = (300, 400), font="SF Hello");
screen = display(scene)
campixel!(scene);

nrows = 4
ncols = 1

maingl = GridLayout(
    nrows, ncols,
    parent = scene,
    alignmode = Outside(5, 5, 5, 5))

las = [maingl[i, j] = LayoutedAxis(scene) for i in 1:nrows, j in 1:ncols]

for i in 1:nrows, j in 1:ncols

    scatter!(las[i, j], rand(200, 2) .+ [i j])

    i > 1 && (las[i, j].attributes.titlevisible = false)
    j > 1 && (las[i, j].attributes.ylabelvisible = false)
    j > 1 && (las[i, j].attributes.yticklabelsvisible = false)
    j > 1 && (las[i, j].attributes.yticksvisible = false)
    i < nrows && (las[i, j].attributes.xticklabelsvisible = false)
    i < nrows && (las[i, j].attributes.xticksvisible = false)
    i < nrows && (las[i, j].attributes.xlabelvisible = false)
end

linkxaxes!(las...)
linkyaxes!(las...)

maingl[0, :] = LayoutedText(scene, text="Super Title", textsize=6)
maingl[2:end, end+1] = LayoutedText(scene, text="Side Title", textsize=6, rotation=-pi/2)
scene

```

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [November 21, 2019, 8:57am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/7 "2019-11-21T08:57:39Z")

</div>

That looks exactly like what I wanted. Perhaps I didn’t manage to update everything properly. I’ll try again in a bit.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 21, 2019, 9:14am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/8 "2019-11-21T09:14:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [November 22, 2019, 9:37am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/9 "2019-11-22T09:37:29Z")

</div>

Hm, it seems like I still get the same error, even after updating:

```julia
julia> versioninfo()
Julia Version 1.1.1
Commit 55e36cc (2019-05-16 04:10 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin15.6.0)
  CPU: Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

(MakieLayoutTests) pkg> st
    Status `~/Documents/programming/julia/MakieLayoutTests/Project.toml`
  [ee78f7c6] Makie v0.9.5
  [5a521ce4] MakieLayout v0.1.5 #master (https://github.com/jkrumbiegel/MakieLayout.jl.git)

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 22, 2019, 11:43am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/10 "2019-11-22T11:43:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 22, 2019, 12:15pm UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/11 "2019-11-22T12:15:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [November 27, 2019, 7:25am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/12 "2019-11-27T07:25:14Z")

</div>

You were right in thinking that my julia version was the source of the problem. Once I upgraded to 1.3, the error went away.

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [November 27, 2019, 8:15am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/13 "2019-11-27T08:15:49Z")

</div>

I just wanted to share my appreciation for this package. To me, this really makes Makie an excellent candidate for producing publication quality plots : )

---

<div class="post-metadata">

**Author:** ![rapus95](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rapus95/32/3773_2.png) [@rapus95](https://discourse.julialang.org/u/rapus95)\
**Post date:** [December 16, 2019, 3:55pm UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/14 "2019-12-16T15:55:14Z")

</div>

Is this the way to go to keep axes fixed in place when zooming/panning?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 16, 2019, 10:41pm UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/15 "2019-12-16T22:41:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rapus95](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rapus95/32/3773_2.png) [@rapus95](https://discourse.julialang.org/u/rapus95)\
**Post date:** [December 17, 2019, 10:07am UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/16 "2019-12-17T10:07:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rapus95](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rapus95/32/3773_2.png) [@rapus95](https://discourse.julialang.org/u/rapus95)\
**Post date:** [December 17, 2019, 1:57pm UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/17 "2019-12-17T13:57:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rapus95](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rapus95/32/3773_2.png) [@rapus95](https://discourse.julialang.org/u/rapus95)\
**Post date:** [December 17, 2019, 4:42pm UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/18 "2019-12-17T16:42:26Z")

</div>

Btw what is the state of serious threading (Julia 1.3) in MakieLayout and Makie?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 18, 2019, 1:07pm UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/19 "2019-12-18T13:07:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Balinus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balinus/32/243_2.png) [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Post date:** [December 18, 2019, 2:56pm UTC](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218/20 "2019-12-18T14:56:09Z")

</div>

Looks useful, thanks!

[Next page](https://discourse.julialang.org/t/ann-makielayout-jl-a-layout-manager-for-makie-jl/31218.md?page=2)
