Bbs/legendfontx (#4119)
* revert legendfont being determant * format * fix precompiles
This commit is contained in:
parent
e31d056820
commit
95fd48ed9b
@ -241,8 +241,6 @@ function _precompile_()
|
|||||||
Base.precompile(Tuple{typeof(_update_min_padding!),GridLayout})
|
Base.precompile(Tuple{typeof(_update_min_padding!),GridLayout})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{GRBackend},Subplot{GRBackend},Dict{Symbol, Any},Int64,Bool})
|
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{GRBackend},Subplot{GRBackend},Dict{Symbol, Any},Int64,Bool})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{PlotlyBackend},Subplot{PlotlyBackend},Dict{Symbol, Any},Int64,Bool})
|
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{PlotlyBackend},Subplot{PlotlyBackend},Dict{Symbol, Any},Int64,Bool})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_legend),Subplot{GRBackend},Dict{Symbol, Any}})
|
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_legend),Subplot{PlotlyBackend},Dict{Symbol, Any}})
|
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{GRBackend},Vector{Any}})
|
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{GRBackend},Vector{Any}})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{PlotlyBackend},Vector{Any}})
|
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{PlotlyBackend},Vector{Any}})
|
||||||
Base.precompile(Tuple{typeof(axis_limits),Subplot{GRBackend},Symbol,Bool,Bool})
|
Base.precompile(Tuple{typeof(axis_limits),Subplot{GRBackend},Symbol,Bool,Bool})
|
||||||
|
|||||||
@ -272,8 +272,6 @@ function _precompile_()
|
|||||||
Base.precompile(Tuple{typeof(_update_min_padding!),GridLayout})
|
Base.precompile(Tuple{typeof(_update_min_padding!),GridLayout})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{GRBackend},Subplot{GRBackend},Dict{Symbol, Any},Int64,Bool})
|
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{GRBackend},Subplot{GRBackend},Dict{Symbol, Any},Int64,Bool})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{PlotlyBackend},Subplot{PlotlyBackend},Dict{Symbol, Any},Int64,Bool})
|
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{PlotlyBackend},Subplot{PlotlyBackend},Dict{Symbol, Any},Int64,Bool})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_legend),Subplot{GRBackend},Dict{Symbol, Any}})
|
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_legend),Subplot{PlotlyBackend},Dict{Symbol, Any}})
|
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{GRBackend},Vector{Any}})
|
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{GRBackend},Vector{Any}})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{PlotlyBackend},Vector{Any}})
|
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{PlotlyBackend},Vector{Any}})
|
||||||
Base.precompile(Tuple{typeof(annotate!),AbstractVector{<:Tuple}})
|
Base.precompile(Tuple{typeof(annotate!),AbstractVector{<:Tuple}})
|
||||||
|
|||||||
@ -181,8 +181,6 @@ function _precompile_()
|
|||||||
Base.precompile(Tuple{typeof(_update_min_padding!),GridLayout})
|
Base.precompile(Tuple{typeof(_update_min_padding!),GridLayout})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{GRBackend},Subplot{GRBackend},Dict{Symbol, Any},Int64,Bool})
|
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{GRBackend},Subplot{GRBackend},Dict{Symbol, Any},Int64,Bool})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{PlotlyBackend},Subplot{PlotlyBackend},Dict{Symbol, Any},Int64,Bool})
|
Base.precompile(Tuple{typeof(_update_subplot_args),Plot{PlotlyBackend},Subplot{PlotlyBackend},Dict{Symbol, Any},Int64,Bool})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_legend),Subplot{GRBackend},Dict{Symbol, Any}})
|
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_legend),Subplot{PlotlyBackend},Dict{Symbol, Any}})
|
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{GRBackend},Vector{Any}})
|
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{GRBackend},Vector{Any}})
|
||||||
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{PlotlyBackend},Vector{Any}})
|
Base.precompile(Tuple{typeof(_update_subplot_periphery),Subplot{PlotlyBackend},Vector{Any}})
|
||||||
Base.precompile(Tuple{typeof(annotate!),AbstractVector{<:Tuple}})
|
Base.precompile(Tuple{typeof(annotate!),AbstractVector{<:Tuple}})
|
||||||
|
|||||||
39
src/args.jl
39
src/args.jl
@ -1347,7 +1347,12 @@ function processFontArg!(plotattributes::AKW, fontname::Symbol, arg)
|
|||||||
T = typeof(arg)
|
T = typeof(arg)
|
||||||
if T <: Font
|
if T <: Font
|
||||||
plotattributes[Symbol(fontname, :family)] = arg.family
|
plotattributes[Symbol(fontname, :family)] = arg.family
|
||||||
plotattributes[Symbol(fontname, :size)] = arg.pointsize
|
# TODO: this is neccessary in the transition from old fontsize to new font_pointsize and should be removed when it is completed
|
||||||
|
if in(Symbol(fontname, :size), _all_args)
|
||||||
|
plotattributes[Symbol(fontname, :size)] = arg.pointsize
|
||||||
|
else
|
||||||
|
plotattributes[Symbol(fontname, :_pointsize)] = arg.pointsize
|
||||||
|
end
|
||||||
plotattributes[Symbol(fontname, :halign)] = arg.halign
|
plotattributes[Symbol(fontname, :halign)] = arg.halign
|
||||||
plotattributes[Symbol(fontname, :valign)] = arg.valign
|
plotattributes[Symbol(fontname, :valign)] = arg.valign
|
||||||
plotattributes[Symbol(fontname, :rotation)] = arg.rotation
|
plotattributes[Symbol(fontname, :rotation)] = arg.rotation
|
||||||
@ -1368,7 +1373,11 @@ function processFontArg!(plotattributes::AKW, fontname::Symbol, arg)
|
|||||||
plotattributes[Symbol(fontname, :family)] = string(arg)
|
plotattributes[Symbol(fontname, :family)] = string(arg)
|
||||||
end
|
end
|
||||||
elseif typeof(arg) <: Integer
|
elseif typeof(arg) <: Integer
|
||||||
plotattributes[Symbol(fontname, :size)] = arg
|
if in(Symbol(fontname, :size), _all_args)
|
||||||
|
plotattributes[Symbol(fontname, :size)] = arg
|
||||||
|
else
|
||||||
|
plotattributes[Symbol(fontname, :_pointsize)] = arg
|
||||||
|
end
|
||||||
elseif typeof(arg) <: Real
|
elseif typeof(arg) <: Real
|
||||||
plotattributes[Symbol(fontname, :rotation)] = convert(Float64, arg)
|
plotattributes[Symbol(fontname, :rotation)] = convert(Float64, arg)
|
||||||
else
|
else
|
||||||
@ -1487,7 +1496,8 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
for fontname in (:titlefont, :legendtitlefont, :plot_titlefont, :colorbar_titlefont)
|
for fontname in
|
||||||
|
(:titlefont, :legend_title_font, :plot_titlefont, :colorbar_titlefont, :legend_font)
|
||||||
args = RecipesPipeline.pop_kw!(plotattributes, fontname, ())
|
args = RecipesPipeline.pop_kw!(plotattributes, fontname, ())
|
||||||
for arg in wraptuple(args)
|
for arg in wraptuple(args)
|
||||||
processFontArg!(plotattributes, fontname, arg)
|
processFontArg!(plotattributes, fontname, arg)
|
||||||
@ -1957,29 +1967,6 @@ function _update_subplot_colors(sp::Subplot)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _update_subplot_legend(sp::Subplot, plotattributes_in)
|
|
||||||
f_attr = NamedTuple(
|
|
||||||
k => plotattributes_in[Symbol(:legend_font_, k)] for
|
|
||||||
k in (:family, :pointsize, :valign, :halign, :rotation, :color) if
|
|
||||||
haskey(plotattributes_in, Symbol(:legend_font_, k))
|
|
||||||
)
|
|
||||||
#! format: off
|
|
||||||
match_attr = NamedTuple(
|
|
||||||
(
|
|
||||||
lk = Symbol(:legend_font_, k);
|
|
||||||
k =>
|
|
||||||
haskey(_match_map, lk) ? sp[lk] :
|
|
||||||
haskey(plotattributes_in, :legend_font) ?
|
|
||||||
getproperty(plotattributes_in[:legend_font], k) :
|
|
||||||
haskey(sp.attr, :legend_font) ?
|
|
||||||
getproperty(sp.attr[:legend_font], k) :
|
|
||||||
default(plotattributes_in, lk)
|
|
||||||
) for k in (:family, :pointsize, :valign, :halign, :rotation, :color)
|
|
||||||
)
|
|
||||||
#! format: on
|
|
||||||
sp.attr[:legend_font] = font(; merge(match_attr, f_attr)...)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _update_axis(
|
function _update_axis(
|
||||||
plt::Plot,
|
plt::Plot,
|
||||||
sp::Subplot,
|
sp::Subplot,
|
||||||
|
|||||||
@ -275,7 +275,6 @@ function _subplot_setup(plt::Plot, plotattributes::AKW, kw_list::Vector{KW})
|
|||||||
get(sp_attrs, sp, KW())
|
get(sp_attrs, sp, KW())
|
||||||
end
|
end
|
||||||
_update_subplot_args(plt, sp, attr, idx, false)
|
_update_subplot_args(plt, sp, attr, idx, false)
|
||||||
_update_subplot_legend(sp, attr)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# do we need to link any axes together?
|
# do we need to link any axes together?
|
||||||
|
|||||||
@ -986,7 +986,14 @@ titlefont(sp::Subplot) = font(;
|
|||||||
color = sp[:titlefontcolor],
|
color = sp[:titlefontcolor],
|
||||||
)
|
)
|
||||||
|
|
||||||
legendfont(sp::Subplot) = sp[:legend_font]
|
legendfont(sp::Subplot) = font(;
|
||||||
|
family = sp[:legend_font_family],
|
||||||
|
pointsize = sp[:legend_font_pointsize],
|
||||||
|
valign = sp[:legend_font_valign],
|
||||||
|
halign = sp[:legend_font_halign],
|
||||||
|
rotation = sp[:legend_font_rotation],
|
||||||
|
color = sp[:legend_font_color],
|
||||||
|
)
|
||||||
|
|
||||||
legendtitlefont(sp::Subplot) = font(;
|
legendtitlefont(sp::Subplot) = font(;
|
||||||
family = sp[:legend_title_font_family],
|
family = sp[:legend_title_font_family],
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using Plots, Test, Colors
|
using Plots, Test, Plots.Colors
|
||||||
|
|
||||||
const PLOTS_DEFAULTS = Dict(:theme => :wong2, :fontfamily => :palantino)
|
const PLOTS_DEFAULTS = Dict(:theme => :wong2, :fontfamily => :palantino)
|
||||||
Plots.__init__()
|
Plots.__init__()
|
||||||
@ -93,4 +93,9 @@ end # testset
|
|||||||
# match mechanism
|
# match mechanism
|
||||||
@test sp[:legend_font_color] == sp[:foreground_color_subplot]
|
@test sp[:legend_font_color] == sp[:foreground_color_subplot]
|
||||||
@test Plots.legendfont(sp).color == sp[:foreground_color_subplot]
|
@test Plots.legendfont(sp).color == sp[:foreground_color_subplot]
|
||||||
|
|
||||||
|
# magic invocation
|
||||||
|
@test_nowarn sp = plot(; legendfont = 12)[1]
|
||||||
|
@test sp[:legend_font_pointsize] == 12
|
||||||
|
@test Plots.legendfont(sp).pointsize == 12
|
||||||
end # testset
|
end # testset
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user