Merge pull request #692 from mkborregaard/showlibrary
Update Plots to use color libraries
This commit is contained in:
commit
032f5a5dab
@ -805,3 +805,47 @@ abline!(args...; kw...) = abline!(current(), args...; kw...)
|
|||||||
seriestype --> :scatter
|
seriestype --> :scatter
|
||||||
real(cp.args[1]), imag(cp.args[1])
|
real(cp.args[1]), imag(cp.args[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Color Gradients
|
||||||
|
|
||||||
|
@userplot ShowLibrary
|
||||||
|
@recipe function f(cl::ShowLibrary)
|
||||||
|
if !(length(cl.args) == 1 && isa(cl.args[1], Symbol))
|
||||||
|
error("showlibrary takes the name of a color library as a Symbol")
|
||||||
|
end
|
||||||
|
|
||||||
|
library = PlotUtils.color_libraries[cl.args[1]]
|
||||||
|
z = sqrt.((1:15)*(1:20)')
|
||||||
|
|
||||||
|
seriestype := :heatmap
|
||||||
|
ticks := nothing
|
||||||
|
legend := false
|
||||||
|
|
||||||
|
layout --> length(library.lib)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
for grad in sort(collect(keys(library.lib)))
|
||||||
|
@series begin
|
||||||
|
seriescolor := cgrad(grad, cl.args[1])
|
||||||
|
title := string(grad)
|
||||||
|
subplot := i += 1
|
||||||
|
z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@userplot ShowGradient
|
||||||
|
@recipe function f(grad::ShowGradient)
|
||||||
|
if !(length(grad.args) == 1 && isa(grad.args[1], Symbol))
|
||||||
|
error("showgradient takes the name of a color gradient as a Symbol")
|
||||||
|
end
|
||||||
|
z = sqrt.((1:15)*(1:20)')
|
||||||
|
seriestype := :heatmap
|
||||||
|
ticks := nothing
|
||||||
|
legend := false
|
||||||
|
seriescolor := grad.args[1]
|
||||||
|
title := string(grad.args[1])
|
||||||
|
z
|
||||||
|
end
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
function theme(s::Symbol; kw...)
|
function theme(s::Symbol; kw...)
|
||||||
# reset?
|
# reset?
|
||||||
if s == :none || s == :default
|
if s == :none || s == :default
|
||||||
PlotUtils._default_gradient[] = :inferno
|
PlotUtils.clibrary(:Plots)
|
||||||
|
PlotUtils.default_cgrad(default = :sequential, sequential = :inferno)
|
||||||
default(;
|
default(;
|
||||||
bg = :white,
|
bg = :white,
|
||||||
bglegend = :match,
|
bglegend = :match,
|
||||||
@ -23,7 +24,8 @@ function theme(s::Symbol; kw...)
|
|||||||
# update the default gradient and other defaults
|
# update the default gradient and other defaults
|
||||||
thm = PlotThemes._themes[s]
|
thm = PlotThemes._themes[s]
|
||||||
if thm.gradient != nothing
|
if thm.gradient != nothing
|
||||||
PlotUtils._default_gradient[] = PlotThemes.gradient_name(s)
|
PlotUtils.clibrary(:misc)
|
||||||
|
PlotUtils.default_cgrad(default = :sequential, sequential = PlotThemes.gradient_name(s))
|
||||||
end
|
end
|
||||||
default(;
|
default(;
|
||||||
bg = thm.bg_secondary,
|
bg = thm.bg_secondary,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user