set font and matching
This commit is contained in:
parent
f430953b2b
commit
bcdb212f2d
@ -1949,8 +1949,9 @@ end
|
|||||||
|
|
||||||
function _update_subplot_legend(sp::Subplot, plotattributes_in)
|
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)))
|
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)))
|
||||||
|
match_attr = NamedTuple( k => sp[Symbol(:legend_font_, k)] for k in (:family, :pointsize, :valign, :halign, :rotation, :color) if haskey(_match_map, Symbol(:legend_font_, k)))
|
||||||
sp.attr[:legend_font] = font(default(plotattributes_in, :legend_font);
|
sp.attr[:legend_font] = font(default(plotattributes_in, :legend_font);
|
||||||
f_attr...
|
merge(f_attr, match_attr)...
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -246,6 +246,7 @@ function font(args...; kw...)
|
|||||||
|
|
||||||
for arg in args
|
for arg in args
|
||||||
T = typeof(arg)
|
T = typeof(arg)
|
||||||
|
@assert arg !== :match
|
||||||
|
|
||||||
if T == Font
|
if T == Font
|
||||||
family = arg.family
|
family = arg.family
|
||||||
@ -269,12 +270,12 @@ function font(args...; kw...)
|
|||||||
catch
|
catch
|
||||||
family = string(arg)
|
family = string(arg)
|
||||||
end
|
end
|
||||||
elseif typeof(arg) <: Integer
|
elseif T <: Integer
|
||||||
pointsize = arg
|
pointsize = arg
|
||||||
elseif typeof(arg) <: Real
|
elseif T <: Real
|
||||||
rotation = convert(Float64, arg)
|
rotation = convert(Float64, arg)
|
||||||
else
|
else
|
||||||
@warn "Unused font arg: $arg ($(typeof(arg)))"
|
@warn "Unused font arg: $arg ($T)"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -262,8 +262,8 @@ function _subplot_setup(plt::Plot, plotattributes::AKW, kw_list::Vector{KW})
|
|||||||
else
|
else
|
||||||
get(sp_attrs, sp, KW())
|
get(sp_attrs, sp, KW())
|
||||||
end
|
end
|
||||||
_update_subplot_legend(sp, attr)
|
|
||||||
_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?
|
||||||
|
|||||||
@ -994,14 +994,7 @@ titlefont(sp::Subplot) = font(;
|
|||||||
color = sp[:titlefontcolor],
|
color = sp[:titlefontcolor],
|
||||||
)
|
)
|
||||||
|
|
||||||
legendfont(sp::Subplot) = font(;
|
legendfont(sp::Subplot) = sp[:legend_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],
|
||||||
|
|||||||
@ -6,7 +6,7 @@ Plots.__init__()
|
|||||||
@testset "Loading theme" begin
|
@testset "Loading theme" begin
|
||||||
pl = plot(1:5)
|
pl = plot(1:5)
|
||||||
@test pl[1][1][:seriescolor] == RGBA(colorant"black")
|
@test pl[1][1][:seriescolor] == RGBA(colorant"black")
|
||||||
@test guidefont(pl[1][:xaxis]).family == "palantino"
|
@test Plots.guidefont(pl[1][:xaxis]).family == "palantino"
|
||||||
end
|
end
|
||||||
|
|
||||||
empty!(PLOTS_DEFAULTS)
|
empty!(PLOTS_DEFAULTS)
|
||||||
@ -69,5 +69,10 @@ end # testset
|
|||||||
@test p[1][:legend_foreground_color] == RGBA{Float64}(0.0, 0.5019607843137255, 0.0, 1.0)
|
@test p[1][:legend_foreground_color] == RGBA{Float64}(0.0, 0.5019607843137255, 0.0, 1.0)
|
||||||
|
|
||||||
#setting whole font
|
#setting whole font
|
||||||
@test plot(1:5, legendfont=font(12))[1][:legend_font_pointsize] == 12
|
sp = plot(1:5, legendfont=font(12), legend_font_halign = :left, foreground_color_subplot = :red)[1]
|
||||||
|
@test Plots.legendfont(sp).pointsize == 12
|
||||||
|
@test Plots.legendfont(sp).halign == :left
|
||||||
|
# match mechanism
|
||||||
|
@test sp[:legend_font_color] == sp[:foreground_color_subplot]
|
||||||
|
@test Plots.legendfont(sp).color == sp[:foreground_color_subplot]
|
||||||
end # testset
|
end # testset
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user