improvements to bbox construction and inset subplots
This commit is contained in:
parent
f6d501f69e
commit
b6652b7619
@ -432,6 +432,7 @@ add_aliases(:title_location, :title_loc, :titleloc, :title_position, :title_pos,
|
|||||||
add_aliases(:series_annotations, :series_ann, :seriesann, :series_anns, :seriesanns, :series_annotation)
|
add_aliases(:series_annotations, :series_ann, :seriesann, :series_anns, :seriesanns, :series_annotation)
|
||||||
add_aliases(:html_output_format, :format, :fmt, :html_format)
|
add_aliases(:html_output_format, :format, :fmt, :html_format)
|
||||||
add_aliases(:orientation, :direction, :dir)
|
add_aliases(:orientation, :direction, :dir)
|
||||||
|
add_aliases(:inset_subplots, :inset, :floating)
|
||||||
|
|
||||||
|
|
||||||
# add all pluralized forms to the _keyAliases dict
|
# add all pluralized forms to the _keyAliases dict
|
||||||
|
|||||||
@ -101,19 +101,46 @@ end
|
|||||||
|
|
||||||
Base.show(io::IO, layout::AbstractLayout) = print(io, "$(typeof(layout))$(size(layout))")
|
Base.show(io::IO, layout::AbstractLayout) = print(io, "$(typeof(layout))$(size(layout))")
|
||||||
|
|
||||||
|
make_measure_hor(n::Number) = n * w
|
||||||
|
make_measure_hor(m::Measure) = m
|
||||||
|
|
||||||
|
make_measure_vert(n::Number) = n * h
|
||||||
|
make_measure_vert(m::Measure) = m
|
||||||
|
|
||||||
|
|
||||||
|
function bbox(x, y, w, h, oarg1::Symbol, originargs::Symbol...)
|
||||||
|
oargs = vcat(oarg1, originargs...)
|
||||||
|
orighor = :left
|
||||||
|
origver = :top
|
||||||
|
for oarg in oargs
|
||||||
|
if oarg in (:left, :right)
|
||||||
|
orighor = oarg
|
||||||
|
elseif oarg in (:top, :bottom)
|
||||||
|
origver = oarg
|
||||||
|
else
|
||||||
|
warn("Unused origin arg in bbox construction: $oarg")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
bbox(x, y, w, h; h_anchor = orighor, v_anchor = origver)
|
||||||
|
end
|
||||||
|
|
||||||
# create a new bbox
|
# create a new bbox
|
||||||
function bbox(x, y, w, h; h_anchor = :left, v_anchor = :top)
|
function bbox(x, y, width, height; h_anchor = :left, v_anchor = :top)
|
||||||
|
x = make_measure_hor(x)
|
||||||
|
y = make_measure_vert(y)
|
||||||
|
width = make_measure_hor(width)
|
||||||
|
height = make_measure_vert(height)
|
||||||
left = if h_anchor == :left
|
left = if h_anchor == :left
|
||||||
x
|
x
|
||||||
else
|
else
|
||||||
x - w * (h_anchor == :right ? 1.0 : 0.5)
|
1w - x - width
|
||||||
end
|
end
|
||||||
top = if v_anchor == :top
|
top = if v_anchor == :top
|
||||||
y
|
y
|
||||||
else
|
else
|
||||||
y - h * (v_anchor == :bottom ? 1.0 : 0.5)
|
1h - y - height
|
||||||
end
|
end
|
||||||
BoundingBox(left, top, w, h)
|
BoundingBox(left, top, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
# this is the available area for drawing everything in this layout... as percentages of total canvas
|
# this is the available area for drawing everything in this layout... as percentages of total canvas
|
||||||
|
|||||||
@ -442,6 +442,9 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
# handle inset subplots
|
# handle inset subplots
|
||||||
insets = plt[:inset_subplots]
|
insets = plt[:inset_subplots]
|
||||||
if insets != nothing
|
if insets != nothing
|
||||||
|
if !(typeof(insets) <: AVec)
|
||||||
|
insets = [insets]
|
||||||
|
end
|
||||||
for inset in insets
|
for inset in insets
|
||||||
parent, bb = is_2tuple(inset) ? inset : (nothing, inset)
|
parent, bb = is_2tuple(inset) ? inset : (nothing, inset)
|
||||||
P = typeof(parent)
|
P = typeof(parent)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user