take legend font attributes from existing font

This commit is contained in:
Simon Christ 2022-02-11 11:12:37 +01:00
parent 6c67908a3a
commit 1924eeeff6
2 changed files with 11 additions and 4 deletions

View File

@ -1059,13 +1059,13 @@ end
""" """
`default(key)` returns the current default value for that key. `default(key)` returns the current default value for that key.
`default(key, value)` sets the current default value for that key. `default(key, value)` sets the current default value for that key.
`default(; kw...)` will set the current default value for each key/value pair. `default(; kw...)` will set the current default value for each key/value pair.
`default(plotattributes, key)` returns the key from plotattributes if it exists, otherwise `default(key)`. `default(plotattributes, key)` returns the key from plotattributes if it exists, otherwise `default(key)`.
""" """
function default(k::Symbol) function default(k::Symbol)
k = get(_keyAliases, k, k) k = get(_keyAliases, k, k)
@ -1968,6 +1968,8 @@ function _update_subplot_legend(sp::Subplot, plotattributes_in)
haskey(_match_map, lk) ? sp[lk] : haskey(_match_map, lk) ? sp[lk] :
haskey(plotattributes_in, :legend_font) ? haskey(plotattributes_in, :legend_font) ?
getproperty(plotattributes_in[:legend_font], k) : getproperty(plotattributes_in[:legend_font], k) :
haskey(sp.attr, :legend_font) ?
getproperty(sp.attr[:legend_font], k) :
default(plotattributes_in, lk) default(plotattributes_in, lk)
) for k in (:family, :pointsize, :valign, :halign, :rotation, :color) ) for k in (:family, :pointsize, :valign, :halign, :rotation, :color)
) )

View File

@ -76,6 +76,11 @@ end # testset
@test p[1][:legend_background_color] == RGBA{Float64}(0.0, 1.0, 1.0, 1.0) @test p[1][:legend_background_color] == RGBA{Float64}(0.0, 1.0, 1.0, 1.0)
@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)
#remember settings
plot(legend_font_pointsize = 20)
sp = plot!(label = "R")[1]
@test Plots.legendfont(sp).pointsize == 20
#setting whole font #setting whole font
sp = plot( sp = plot(
1:5, 1:5,