add new heme() function

This commit is contained in:
Daniel Schwabeneder 2017-12-04 09:16:00 +01:00
parent 863ec08681
commit 899afd625a

View File

@ -4,43 +4,53 @@
Specify the colour theme for plots.
"""
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
defaults = merge(_initial_defaults..., s.defaults, kw)
if haskey(s.defaults, :gradient)
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...
)
default(; defaults...)
return
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)