Merge pull request #2320 from korsbo/layout_colon
Support colons in layout keyword argument.
This commit is contained in:
commit
140afeb53d
@ -469,7 +469,7 @@ function layout_args(plotattributes::KW)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function layout_args(plotattributes::KW, n_override::Integer)
|
function layout_args(plotattributes::KW, n_override::Integer)
|
||||||
layout, n = layout_args(get(plotattributes, :layout, n_override))
|
layout, n = layout_args(n_override, get(plotattributes, :layout, n_override))
|
||||||
if n != n_override
|
if n != n_override
|
||||||
error("When doing layout, n ($n) != n_override ($(n_override)). You're probably trying to force existing plots into a layout that doesn't fit them.")
|
error("When doing layout, n ($n) != n_override ($(n_override)). You're probably trying to force existing plots into a layout that doesn't fit them.")
|
||||||
end
|
end
|
||||||
@ -481,12 +481,27 @@ function layout_args(n::Integer)
|
|||||||
GridLayout(nr, nc), n
|
GridLayout(nr, nc), n
|
||||||
end
|
end
|
||||||
|
|
||||||
function layout_args(sztup::NTuple{2,I}) where I<:Integer
|
function layout_args(sztup::NTuple{2, Integer})
|
||||||
nr, nc = sztup
|
nr, nc = sztup
|
||||||
GridLayout(nr, nc), nr*nc
|
GridLayout(nr, nc), nr*nc
|
||||||
end
|
end
|
||||||
|
|
||||||
function layout_args(sztup::NTuple{3,I}) where I<:Integer
|
layout_args(n_override::Integer, n::Integer) = layout_args(n)
|
||||||
|
layout_args(n, sztup::NTuple{2, Integer}) = layout_args(sztup)
|
||||||
|
|
||||||
|
function layout_args(n, sztup::Tuple{Colon, Integer})
|
||||||
|
nc = sztup[2]
|
||||||
|
nr = ceil(Int, n / nc)
|
||||||
|
GridLayout(nr, nc), n
|
||||||
|
end
|
||||||
|
|
||||||
|
function layout_args(n, sztup::Tuple{Integer, Colon})
|
||||||
|
nr = sztup[1]
|
||||||
|
nc = ceil(Int, n / nr)
|
||||||
|
GridLayout(nr, nc), n
|
||||||
|
end
|
||||||
|
|
||||||
|
function layout_args(sztup::NTuple{3, Integer})
|
||||||
n, nr, nc = sztup
|
n, nr, nc = sztup
|
||||||
nr, nc = compute_gridsize(n, nr, nc)
|
nr, nc = compute_gridsize(n, nr, nc)
|
||||||
GridLayout(nr, nc), n
|
GridLayout(nr, nc), n
|
||||||
@ -499,6 +514,8 @@ function layout_args(layout::GridLayout)
|
|||||||
layout, n
|
layout, n
|
||||||
end
|
end
|
||||||
|
|
||||||
|
layout_args(n_override::Integer, layout::GridLayout) = layout_args(layout)
|
||||||
|
|
||||||
layout_args(huh) = error("unhandled layout type $(typeof(huh)): $huh")
|
layout_args(huh) = error("unhandled layout type $(typeof(huh)): $huh")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user