Merge pull request #3741 from t-bltg/scalefontsizes
Rework fontscales - cleanup
This commit is contained in:
commit
478868a6a2
48
src/args.jl
48
src/args.jl
@ -524,12 +524,25 @@ const _initial_defaults = deepcopy(_all_defaults)
|
|||||||
const _initial_axis_defaults = deepcopy(_axis_defaults)
|
const _initial_axis_defaults = deepcopy(_axis_defaults)
|
||||||
|
|
||||||
# to be able to reset font sizes to initial values
|
# to be able to reset font sizes to initial values
|
||||||
const _initial_fontsizes = Dict(:titlefontsize => _subplot_defaults[:titlefontsize],
|
const _initial_plt_fontsizes = Dict(
|
||||||
:legendfontsize => _subplot_defaults[:legendfontsize],
|
:plot_titlefontsize => _plot_defaults[:plot_titlefontsize],
|
||||||
:legendtitlefontsize => _subplot_defaults[:legendtitlefontsize],
|
)
|
||||||
:annotationfontsize => _subplot_defaults[:annotationfontsize],
|
|
||||||
:tickfontsize => _axis_defaults[:tickfontsize],
|
const _initial_sp_fontsizes = Dict(
|
||||||
:guidefontsize => _axis_defaults[:guidefontsize])
|
:titlefontsize => _subplot_defaults[:titlefontsize],
|
||||||
|
:legendfontsize => _subplot_defaults[:legendfontsize],
|
||||||
|
:legendtitlefontsize => _subplot_defaults[:legendtitlefontsize],
|
||||||
|
:annotationfontsize => _subplot_defaults[:annotationfontsize],
|
||||||
|
:colorbar_tickfontsize => _subplot_defaults[:colorbar_tickfontsize],
|
||||||
|
:colorbar_titlefontsize => _subplot_defaults[:colorbar_titlefontsize],
|
||||||
|
)
|
||||||
|
|
||||||
|
const _initial_ax_fontsizes = Dict(
|
||||||
|
:tickfontsize => _axis_defaults[:tickfontsize],
|
||||||
|
:guidefontsize => _axis_defaults[:guidefontsize],
|
||||||
|
)
|
||||||
|
|
||||||
|
const _initial_fontsizes = merge(_initial_plt_fontsizes, _initial_sp_fontsizes, _initial_ax_fontsizes)
|
||||||
|
|
||||||
const _internal_args =
|
const _internal_args =
|
||||||
[:plot_object, :series_plotindex, :markershape_to_add, :letter, :idxfilter]
|
[:plot_object, :series_plotindex, :markershape_to_add, :letter, :idxfilter]
|
||||||
@ -548,8 +561,7 @@ const _all_subplot_args = sort(union([_subplot_args; _magic_subplot_args]))
|
|||||||
const _all_series_args = sort(union([_series_args; _magic_series_args]))
|
const _all_series_args = sort(union([_series_args; _magic_series_args]))
|
||||||
const _all_plot_args = _plot_args
|
const _all_plot_args = _plot_args
|
||||||
|
|
||||||
const _all_args =
|
const _all_args = sort(union([_all_axis_args; _all_subplot_args; _all_series_args; _all_plot_args]))
|
||||||
sort(union([_all_axis_args; _all_subplot_args; _all_series_args; _all_plot_args]))
|
|
||||||
|
|
||||||
is_subplot_attr(k) = k in _all_subplot_args
|
is_subplot_attr(k) = k in _all_subplot_args
|
||||||
is_series_attr(k) = k in _all_series_args
|
is_series_attr(k) = k in _all_series_args
|
||||||
@ -571,9 +583,7 @@ function aliasesAndAutopick(plotattributes::AKW, sym::Symbol, aliases::Dict{Symb
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function aliases(aliasMap::Dict{Symbol,Symbol}, val)
|
aliases(aliasMap::Dict{Symbol,Symbol}, val) = sortedkeys(filter((k,v)-> v==val, aliasMap))
|
||||||
sortedkeys(filter((k,v)-> v==val, aliasMap))
|
|
||||||
end
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -776,9 +786,7 @@ function default(; reset = true, kw...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function default(plotattributes::AKW, k::Symbol)
|
default(plotattributes::AKW, k::Symbol) = get(plotattributes, k, default(k))
|
||||||
get(plotattributes, k, default(k))
|
|
||||||
end
|
|
||||||
|
|
||||||
function reset_defaults()
|
function reset_defaults()
|
||||||
foreach(merge!, _all_defaults, _initial_defaults)
|
foreach(merge!, _all_defaults, _initial_defaults)
|
||||||
@ -1427,9 +1435,7 @@ function Base.getindex(axis::Axis, k::Symbol)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.getindex(series::Series, k::Symbol)
|
Base.getindex(series::Series, k::Symbol) = series.plotattributes[k]
|
||||||
series.plotattributes[k]
|
|
||||||
end
|
|
||||||
|
|
||||||
Base.setindex!(plt::Plot, v, k::Symbol) = (plt.attr[k] = v)
|
Base.setindex!(plt::Plot, v, k::Symbol) = (plt.attr[k] = v)
|
||||||
Base.setindex!(sp::Subplot, v, k::Symbol) = (sp.attr[k] = v)
|
Base.setindex!(sp::Subplot, v, k::Symbol) = (sp.attr[k] = v)
|
||||||
@ -1611,9 +1617,7 @@ end
|
|||||||
|
|
||||||
has_black_border_for_default(st) = error("The seriestype attribute only accepts Symbols, you passed the $(typeof(st)) $st.")
|
has_black_border_for_default(st) = error("The seriestype attribute only accepts Symbols, you passed the $(typeof(st)) $st.")
|
||||||
has_black_border_for_default(st::Function) = error("The seriestype attribute only accepts Symbols, you passed the function $st.")
|
has_black_border_for_default(st::Function) = error("The seriestype attribute only accepts Symbols, you passed the function $st.")
|
||||||
function has_black_border_for_default(st::Symbol)
|
has_black_border_for_default(st::Symbol) = like_histogram(st) || st in (:hexbin, :bar, :shape)
|
||||||
like_histogram(st) || st in (:hexbin, :bar, :shape)
|
|
||||||
end
|
|
||||||
|
|
||||||
# converts a symbol or string into a Colorant or ColorGradient
|
# converts a symbol or string into a Colorant or ColorGradient
|
||||||
# and assigns a color automatically
|
# and assigns a color automatically
|
||||||
@ -1626,9 +1630,7 @@ function get_series_color(c, sp::Subplot, n::Int, seriestype)
|
|||||||
plot_color(c)
|
plot_color(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_series_color(c::AbstractArray, sp::Subplot, n::Int, seriestype)
|
get_series_color(c::AbstractArray, sp::Subplot, n::Int, seriestype) = map(x->get_series_color(x, sp, n, seriestype), c)
|
||||||
map(x->get_series_color(x, sp, n, seriestype), c)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ensure_gradient!(plotattributes::AKW, csym::Symbol, asym::Symbol)
|
function ensure_gradient!(plotattributes::AKW, csym::Symbol, asym::Symbol)
|
||||||
if plotattributes[csym] isa ColorPalette
|
if plotattributes[csym] isa ColorPalette
|
||||||
|
|||||||
@ -327,12 +327,12 @@ end
|
|||||||
Scales all **current** font sizes by `factor`. For example `scalefontsizes(1.1)` increases all current font sizes by 10%. To reset to initial sizes, use `scalefontsizes()`
|
Scales all **current** font sizes by `factor`. For example `scalefontsizes(1.1)` increases all current font sizes by 10%. To reset to initial sizes, use `scalefontsizes()`
|
||||||
"""
|
"""
|
||||||
function scalefontsizes(factor::Number)
|
function scalefontsizes(factor::Number)
|
||||||
for k in (:titlefontsize, :legendfontsize, :legendtitlefontsize)
|
for k in keys(merge(_initial_plt_fontsizes, _initial_sp_fontsizes))
|
||||||
scalefontsize(k, factor)
|
scalefontsize(k, factor)
|
||||||
end
|
end
|
||||||
|
|
||||||
for letter in (:x,:y,:z)
|
for letter in (:x,:y,:z)
|
||||||
for k in (:guidefontsize, :tickfontsize)
|
for k in keys(_initial_ax_fontsizes)
|
||||||
scalefontsize(Symbol(letter, k), factor)
|
scalefontsize(Symbol(letter, k), factor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -344,7 +344,7 @@ end
|
|||||||
Resets font sizes to initial default values.
|
Resets font sizes to initial default values.
|
||||||
"""
|
"""
|
||||||
function scalefontsizes()
|
function scalefontsizes()
|
||||||
for k in (:titlefontsize, :legendfontsize, :legendtitlefontsize)
|
for k in keys(merge(_initial_plt_fontsizes, _initial_sp_fontsizes))
|
||||||
f = default(k)
|
f = default(k)
|
||||||
if k in keys(_initial_fontsizes)
|
if k in keys(_initial_fontsizes)
|
||||||
factor = f / _initial_fontsizes[k]
|
factor = f / _initial_fontsizes[k]
|
||||||
@ -353,7 +353,7 @@ function scalefontsizes()
|
|||||||
end
|
end
|
||||||
|
|
||||||
for letter in (:x,:y,:z)
|
for letter in (:x,:y,:z)
|
||||||
for k in (:guidefontsize, :tickfontsize)
|
for k in keys(_initial_ax_fontsizes)
|
||||||
if k in keys(_initial_fontsizes)
|
if k in keys(_initial_fontsizes)
|
||||||
f = default(Symbol(letter, k))
|
f = default(Symbol(letter, k))
|
||||||
factor = f / _initial_fontsizes[k]
|
factor = f / _initial_fontsizes[k]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user