allow relative positioning of annotations
This commit is contained in:
parent
4a18098944
commit
bb493a872a
@ -635,26 +635,43 @@ function process_annotation(sp::Subplot, positions::Union{AVec{Symbol},Symbol},
|
|||||||
anns
|
anns
|
||||||
end
|
end
|
||||||
|
|
||||||
function process_any_label(lab, font=Font())
|
process_any_label(lab, font=Font()) = lab isa Tuple ? text(lab...) : text(lab, font)
|
||||||
lab isa Tuple ? text(lab...) : text( lab, font )
|
|
||||||
end
|
_relative_position(xmin, xmax, pos::Length{:pct}) = xmin + pos.value * (xmax - xmin)
|
||||||
|
|
||||||
# Give each annotation coordinates based on specified position
|
# Give each annotation coordinates based on specified position
|
||||||
function locate_annotation(sp::Subplot, pos::Symbol, lab::PlotText)
|
locate_annotation(
|
||||||
position_multiplier = Dict{Symbol, Tuple{Float64,Float64}}(
|
sp::Subplot, pos::Symbol, label::PlotText;
|
||||||
:topleft => (0.1, 0.9),
|
position_multiplier=Dict{Symbol, Tuple{Float64,Float64}}(
|
||||||
:topcenter => (0.5, 0.9),
|
:topleft => (0.1pct, 0.9pct),
|
||||||
:topright => (0.9, 0.9),
|
:topcenter => (0.5pct, 0.9pct),
|
||||||
:bottomleft => (0.1, 0.1),
|
:topright => (0.9pct, 0.9pct),
|
||||||
:bottomcenter => (0.5, 0.1),
|
:bottomleft => (0.1pct, 0.1pct),
|
||||||
:bottomright => (0.9, 0.1),
|
:bottomcenter => (0.5pct, 0.1pct),
|
||||||
|
:bottomright => (0.9pct, 0.1pct),
|
||||||
|
)
|
||||||
|
) = begin
|
||||||
|
x, y = position_multiplier[pos]
|
||||||
|
(
|
||||||
|
_relative_position(axis_limits(sp, :x)..., x),
|
||||||
|
_relative_position(axis_limits(sp, :y)..., y),
|
||||||
|
label
|
||||||
)
|
)
|
||||||
xmin, xmax = ignorenan_extrema(sp[:xaxis])
|
|
||||||
ymin, ymax = ignorenan_extrema(sp[:yaxis])
|
|
||||||
x, y = (xmin, ymin).+ position_multiplier[pos].* (xmax - xmin, ymax - ymin)
|
|
||||||
(x, y, lab)
|
|
||||||
end
|
end
|
||||||
locate_annotation(sp::Subplot, x, y, label::PlotText) = (x, y, label)
|
locate_annotation(sp::Subplot, x, y, label::PlotText) = (x, y, label)
|
||||||
locate_annotation(sp::Subplot, x, y, z, label::PlotText) = (x, y, z, label)
|
locate_annotation(sp::Subplot, x, y, z, label::PlotText) = (x, y, z, label)
|
||||||
|
|
||||||
|
locate_annotation(sp::Subplot, x::Length{:pct}, y::Length{:pct}, label::PlotText) = (
|
||||||
|
_relative_position(axis_limits(sp, :x)..., x),
|
||||||
|
_relative_position(axis_limits(sp, :y)..., y),
|
||||||
|
label
|
||||||
|
)
|
||||||
|
locate_annotation(sp::Subplot, x::Length{:pct}, y::Length{:pct}, z::Length{:pct}, label::PlotText) = (
|
||||||
|
_relative_position(axis_limits(sp, :x)..., x),
|
||||||
|
_relative_position(axis_limits(sp, :y)..., y),
|
||||||
|
_relative_position(axis_limits(sp, :z)..., z),
|
||||||
|
label
|
||||||
|
)
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
"type which represents z-values for colors and sizes (and anything else that might come up)"
|
"type which represents z-values for colors and sizes (and anything else that might come up)"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user