From 6677e0e0a007852f4712005ee5cc0f8ee360d9ce Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Wed, 12 Oct 2016 14:52:30 -0400 Subject: [PATCH] fix link_axes for nested singleton subplot --- src/layouts.jl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/layouts.jl b/src/layouts.jl index dba708ee..6c47949c 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -692,9 +692,22 @@ function link_axes!(axes::Axis...) end end +# figure out which subplots to link +function link_subplots(a::AbstractArray{AbstractLayout}, axissym::Symbol) + subplots = [] + for l in a + if isa(l, Subplot) + push!(subplots, l) + elseif isa(l, GridLayout) && size(l) == (1,1) + push!(subplots, l[1,1]) + end + end + subplots +end + # for some vector or matrix of layouts, filter only the Subplots and link those axes function link_axes!(a::AbstractArray{AbstractLayout}, axissym::Symbol) - subplots = filter(l -> isa(l, Subplot), a) + subplots = link_subplots(a, axissym) axes = [sp.attr[axissym] for sp in subplots] if length(axes) > 0 link_axes!(axes...)