fix link_axes for nested singleton subplot

This commit is contained in:
Thomas Breloff 2016-10-12 14:52:30 -04:00
parent 9d64914e62
commit 6677e0e0a0

View File

@ -692,9 +692,22 @@ function link_axes!(axes::Axis...)
end end
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 # for some vector or matrix of layouts, filter only the Subplots and link those axes
function link_axes!(a::AbstractArray{AbstractLayout}, axissym::Symbol) 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] axes = [sp.attr[axissym] for sp in subplots]
if length(axes) > 0 if length(axes) > 0
link_axes!(axes...) link_axes!(axes...)