update new heme() function
This commit is contained in:
parent
899afd625a
commit
b987331b4f
@ -417,6 +417,7 @@ const _all_defaults = KW[
|
|||||||
]
|
]
|
||||||
|
|
||||||
const _initial_defaults = deepcopy(_all_defaults)
|
const _initial_defaults = deepcopy(_all_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(:titlefont => _subplot_defaults[:titlefontsize],
|
const _initial_fontsizes = Dict(:titlefont => _subplot_defaults[:titlefontsize],
|
||||||
@ -614,7 +615,10 @@ function default(d::KW, k::Symbol)
|
|||||||
get(d, k, default(k))
|
get(d, k, default(k))
|
||||||
end
|
end
|
||||||
|
|
||||||
reset_defaults() = foreach(merge!, _all_defaults, _initial_defaults)
|
function reset_defaults()
|
||||||
|
foreach(merge!, _all_defaults, _initial_defaults)
|
||||||
|
merge!(_axis_defaults, _initial_axis_defaults)
|
||||||
|
end
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -4,53 +4,35 @@
|
|||||||
Specify the colour theme for plots.
|
Specify the colour theme for plots.
|
||||||
"""
|
"""
|
||||||
function theme(s::Symbol; kw...)
|
function theme(s::Symbol; kw...)
|
||||||
defaults = merge(_initial_defaults..., s.defaults, kw)
|
# Reset to defaults to overwrite active team
|
||||||
if haskey(s.defaults, :gradient)
|
reset_defaults()
|
||||||
|
thm = PlotThemes._themes[s]
|
||||||
|
|
||||||
|
# Set the theme's gradient as default
|
||||||
|
if haskey(thm.defaults, :gradient)
|
||||||
PlotUtils.clibrary(:misc)
|
PlotUtils.clibrary(:misc)
|
||||||
PlotUtils.default_cgrad(default = :sequential, sequential = PlotThemes.gradient_name(s))
|
PlotUtils.default_cgrad(default = :sequential, sequential = PlotThemes.gradient_name(s))
|
||||||
|
else
|
||||||
|
PlotUtils.clibrary(:Plots)
|
||||||
|
PlotUtils.default_cgrad(default = :sequential, sequential = :inferno)
|
||||||
end
|
end
|
||||||
default(; defaults...)
|
|
||||||
|
# maybe overwrite the theme's gradient
|
||||||
|
kw = KW(kw)
|
||||||
|
if haskey(kw, :gradient)
|
||||||
|
kwgrad = pop!(kw, :gradient)
|
||||||
|
for clib in clibraries()
|
||||||
|
if kwgrad in cgradients(clib)
|
||||||
|
PlotUtils.clibrary(clib)
|
||||||
|
PlotUtils.default_cgrad(default = :sequential, sequential = kwgrad)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Set the theme's defaults
|
||||||
|
default(; thm.defaults..., kw...)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# function theme(s::Symbol; kw...)
|
|
||||||
# # reset?
|
|
||||||
# if s == :none || s == :default
|
|
||||||
# PlotUtils.clibrary(:Plots)
|
|
||||||
# PlotUtils.default_cgrad(default = :sequential, sequential = :inferno)
|
|
||||||
# default(;
|
|
||||||
# bg = :white,
|
|
||||||
# bglegend = :match,
|
|
||||||
# bginside = :match,
|
|
||||||
# bgoutside = :match,
|
|
||||||
# fg = :auto,
|
|
||||||
# fglegend = :match,
|
|
||||||
# fggrid = :match,
|
|
||||||
# fgaxis = :match,
|
|
||||||
# fgtext = :match,
|
|
||||||
# fgborder = :match,
|
|
||||||
# fgguide = :match,
|
|
||||||
# palette = :auto
|
|
||||||
# )
|
|
||||||
# return
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # update the default gradient and other defaults
|
|
||||||
# thm = PlotThemes._themes[s]
|
|
||||||
# if thm.gradient != nothing
|
|
||||||
# PlotUtils.clibrary(:misc)
|
|
||||||
# PlotUtils.default_cgrad(default = :sequential, sequential = PlotThemes.gradient_name(s))
|
|
||||||
# end
|
|
||||||
# default(;
|
|
||||||
# bg = thm.bg_secondary,
|
|
||||||
# bginside = thm.bg_primary,
|
|
||||||
# fg = thm.lines,
|
|
||||||
# fgtext = thm.text,
|
|
||||||
# fgguide = thm.text,
|
|
||||||
# fglegend = thm.text,
|
|
||||||
# palette = thm.palette,
|
|
||||||
# kw...
|
|
||||||
# )
|
|
||||||
# end
|
|
||||||
|
|
||||||
@deprecate set_theme(s) theme(s)
|
@deprecate set_theme(s) theme(s)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user