add PlotThemes dep, change set_theme to theme
This commit is contained in:
parent
81302c1e9d
commit
b181788dc2
17
src/Plots.jl
17
src/Plots.jl
@ -3,14 +3,12 @@ __precompile__()
|
|||||||
|
|
||||||
module Plots
|
module Plots
|
||||||
|
|
||||||
# using Compat
|
|
||||||
using Reexport
|
using Reexport
|
||||||
# @reexport using Colors
|
|
||||||
# using Requires
|
|
||||||
using FixedSizeArrays
|
using FixedSizeArrays
|
||||||
@reexport using RecipesBase
|
@reexport using RecipesBase
|
||||||
using Base.Meta
|
using Base.Meta
|
||||||
@reexport using PlotUtils
|
@reexport using PlotUtils
|
||||||
|
@reexport using PlotThemes
|
||||||
import Showoff
|
import Showoff
|
||||||
|
|
||||||
export
|
export
|
||||||
@ -29,8 +27,7 @@ export
|
|||||||
KW,
|
KW,
|
||||||
|
|
||||||
wrap,
|
wrap,
|
||||||
set_theme,
|
theme,
|
||||||
add_theme,
|
|
||||||
|
|
||||||
plot,
|
plot,
|
||||||
plot!,
|
plot!,
|
||||||
@ -77,7 +74,6 @@ export
|
|||||||
backend_object,
|
backend_object,
|
||||||
add_backend,
|
add_backend,
|
||||||
aliases,
|
aliases,
|
||||||
# dataframes,
|
|
||||||
|
|
||||||
Shape,
|
Shape,
|
||||||
text,
|
text,
|
||||||
@ -97,8 +93,6 @@ export
|
|||||||
@animate,
|
@animate,
|
||||||
@gif,
|
@gif,
|
||||||
|
|
||||||
# spy,
|
|
||||||
|
|
||||||
test_examples,
|
test_examples,
|
||||||
iter_segments,
|
iter_segments,
|
||||||
coords,
|
coords,
|
||||||
@ -247,11 +241,4 @@ end
|
|||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
# if VERSION >= v"0.4.0-dev+5512"
|
|
||||||
# include("precompile.jl")
|
|
||||||
# _precompile_()
|
|
||||||
# end
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
|
|
||||||
end # module
|
end # module
|
||||||
|
|||||||
133
src/themes.jl
133
src/themes.jl
@ -1,65 +1,78 @@
|
|||||||
|
|
||||||
const _invisible = RGBA(0,0,0,0)
|
# const _invisible = RGBA(0,0,0,0)
|
||||||
|
#
|
||||||
|
# const _themes = KW(
|
||||||
|
# :default => KW(
|
||||||
|
# :bg => :white,
|
||||||
|
# :bglegend => :match,
|
||||||
|
# :bginside => :match,
|
||||||
|
# :bgoutside => :match,
|
||||||
|
# :fg => :auto,
|
||||||
|
# :fglegend => :match,
|
||||||
|
# :fggrid => :match,
|
||||||
|
# :fgaxis => :match,
|
||||||
|
# :fgtext => :match,
|
||||||
|
# :fgborder => :match,
|
||||||
|
# :fgguide => :match,
|
||||||
|
# )
|
||||||
|
# )
|
||||||
|
|
||||||
const _themes = KW(
|
# function add_theme(sym::Symbol, theme::KW)
|
||||||
:default => KW(
|
# _themes[sym] = theme
|
||||||
:bg => :white,
|
# end
|
||||||
:bglegend => :match,
|
#
|
||||||
:bginside => :match,
|
# # add a new theme, using an existing theme as the base
|
||||||
:bgoutside => :match,
|
# function add_theme(sym::Symbol;
|
||||||
:fg => :auto,
|
# base = :default, # start with this theme
|
||||||
:fglegend => :match,
|
# bg = _themes[base][:bg],
|
||||||
:fggrid => :match,
|
# bglegend = _themes[base][:bglegend],
|
||||||
:fgaxis => :match,
|
# bginside = _themes[base][:bginside],
|
||||||
:fgtext => :match,
|
# bgoutside = _themes[base][:bgoutside],
|
||||||
:fgborder => :match,
|
# fg = _themes[base][:fg],
|
||||||
:fgguide => :match,
|
# fglegend = _themes[base][:fglegend],
|
||||||
|
# fggrid = _themes[base][:fggrid],
|
||||||
|
# fgaxis = _themes[base][:fgaxis],
|
||||||
|
# fgtext = _themes[base][:fgtext],
|
||||||
|
# fgborder = _themes[base][:fgborder],
|
||||||
|
# fgguide = _themes[base][:fgguide],
|
||||||
|
# kw...)
|
||||||
|
# _themes[sym] = merge(KW(
|
||||||
|
# :bg => bg,
|
||||||
|
# :bglegend => bglegend,
|
||||||
|
# :bginside => bginside,
|
||||||
|
# :bgoutside => bgoutside,
|
||||||
|
# :fg => fg,
|
||||||
|
# :fglegend => fglegend,
|
||||||
|
# :fggrid => fggrid,
|
||||||
|
# :fgaxis => fgaxis,
|
||||||
|
# :fgtext => fgtext,
|
||||||
|
# :fgborder => fgborder,
|
||||||
|
# :fgguide => fgguide,
|
||||||
|
# ), KW(kw))
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# add_theme(:ggplot2,
|
||||||
|
# bglegend = :lightgray,
|
||||||
|
# bginside = :lightgray,
|
||||||
|
# fg = :black,
|
||||||
|
# fggrid = :white,
|
||||||
|
# fgborder = _invisible,
|
||||||
|
# fgaxis = _invisible
|
||||||
|
# )
|
||||||
|
|
||||||
|
function theme(s::Symbol; kw...)
|
||||||
|
thm = PlotThemes._themes[s]
|
||||||
|
PlotUtils._default_gradient[] = s
|
||||||
|
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...
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
function add_theme(sym::Symbol, theme::KW)
|
|
||||||
_themes[sym] = theme
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# add a new theme, using an existing theme as the base
|
@deprecate set_theme(s) theme(s)
|
||||||
function add_theme(sym::Symbol;
|
|
||||||
base = :default, # start with this theme
|
|
||||||
bg = _themes[base][:bg],
|
|
||||||
bglegend = _themes[base][:bglegend],
|
|
||||||
bginside = _themes[base][:bginside],
|
|
||||||
bgoutside = _themes[base][:bgoutside],
|
|
||||||
fg = _themes[base][:fg],
|
|
||||||
fglegend = _themes[base][:fglegend],
|
|
||||||
fggrid = _themes[base][:fggrid],
|
|
||||||
fgaxis = _themes[base][:fgaxis],
|
|
||||||
fgtext = _themes[base][:fgtext],
|
|
||||||
fgborder = _themes[base][:fgborder],
|
|
||||||
fgguide = _themes[base][:fgguide],
|
|
||||||
kw...)
|
|
||||||
_themes[sym] = merge(KW(
|
|
||||||
:bg => bg,
|
|
||||||
:bglegend => bglegend,
|
|
||||||
:bginside => bginside,
|
|
||||||
:bgoutside => bgoutside,
|
|
||||||
:fg => fg,
|
|
||||||
:fglegend => fglegend,
|
|
||||||
:fggrid => fggrid,
|
|
||||||
:fgaxis => fgaxis,
|
|
||||||
:fgtext => fgtext,
|
|
||||||
:fgborder => fgborder,
|
|
||||||
:fgguide => fgguide,
|
|
||||||
), KW(kw))
|
|
||||||
end
|
|
||||||
|
|
||||||
add_theme(:ggplot2,
|
|
||||||
bglegend = :lightgray,
|
|
||||||
bginside = :lightgray,
|
|
||||||
fg = :black,
|
|
||||||
fggrid = :white,
|
|
||||||
fgborder = _invisible,
|
|
||||||
fgaxis = _invisible
|
|
||||||
)
|
|
||||||
|
|
||||||
function set_theme(sym::Symbol)
|
|
||||||
default(; _themes[sym]...)
|
|
||||||
end
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user