From 70bead1eb1347312f0a929567b5d58ff6d5f823d Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Tue, 5 Dec 2017 22:09:18 +0100 Subject: [PATCH] support old PlotTheme type --- src/themes.jl | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/themes.jl b/src/themes.jl index 40a9e1f8..5107bcde 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -3,13 +3,35 @@ Specify the colour theme for plots. """ -function theme(s::Symbol; kw...) +function theme(s::Symbol, kw...) + thm = PlotThemes._themes[s] + defaults = if :defaults in fieldnames(thm) + thm.defaults + else # old PlotTheme type + defs = KW( + :bg => thm.bg_secondary, + :bginside => thm.bg_primary, + :fg => thm.lines, + :fgtext => thm.text, + :fgguide => thm.text, + :fglegend => thm.text, + :palette => thm.palette, + ) + if thm.gradient != nothing + push!(defs, :gradient => thm.gradient) + end + defs + end + _theme(s, defaults, kw...) +end + + +function _theme(s::Symbol, defaults::KW; kw...) # Reset to defaults to overwrite active theme reset_defaults() - thm = PlotThemes._themes[s] # Set the theme's gradient as default - if haskey(thm.defaults, :gradient) + if haskey(defaults, :gradient) PlotUtils.clibrary(:misc) PlotUtils.default_cgrad(default = :sequential, sequential = PlotThemes.gradient_name(s)) else @@ -31,7 +53,7 @@ function theme(s::Symbol; kw...) end # Set the theme's defaults - default(; thm.defaults..., kw...) + default(; defaults..., kw...) return end