diff --git a/src/args.jl b/src/args.jl index 812345cd..857fa660 100644 --- a/src/args.jl +++ b/src/args.jl @@ -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(:html_output_format, :format, :fmt, :html_format) add_aliases(:orientation, :direction, :dir) +add_aliases(:inset_subplots, :inset, :floating) # add all pluralized forms to the _keyAliases dict diff --git a/src/layouts.jl b/src/layouts.jl index 90892adf..0fd04816 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -101,19 +101,46 @@ end 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 -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 x else - x - w * (h_anchor == :right ? 1.0 : 0.5) + 1w - x - width end top = if v_anchor == :top y else - y - h * (v_anchor == :bottom ? 1.0 : 0.5) + 1h - y - height end - BoundingBox(left, top, w, h) + BoundingBox(left, top, width, height) end # this is the available area for drawing everything in this layout... as percentages of total canvas diff --git a/src/plot.jl b/src/plot.jl index eb10e248..5281b491 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -442,6 +442,9 @@ function _plot!(plt::Plot, d::KW, args...) # handle inset subplots insets = plt[:inset_subplots] if insets != nothing + if !(typeof(insets) <: AVec) + insets = [insets] + end for inset in insets parent, bb = is_2tuple(inset) ? inset : (nothing, inset) P = typeof(parent)