From 2a350df5ebe80fe40e32deed9681f30117e56889 Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Tue, 21 Feb 2017 22:44:32 +0100 Subject: [PATCH 01/14] plot recipe to show color libraries --- src/recipes.jl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/recipes.jl b/src/recipes.jl index 156bda3e..7e0d4dde 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -802,3 +802,33 @@ abline!(args...; kw...) = abline!(current(), args...; kw...) seriestype --> :scatter real(cp.args[1]), imag(cp.args[1]) 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 = clibrary(cl.args[1]) + z = sqrt.((1:20)*(1:15)') + + seriestype := :heatmap + ticks := nothing + legend := false + + layout := length(library.lib) + + i = 0 + for grad in keys(library.lib) + @series begin + seriescolor := cgrad(grad, color_library = cl.args[1]) + title := grad + subplot := i += 1 + z + end + end +end From 4b2ce036e8642dae2c2cda622a938cfc347c199f Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Tue, 21 Feb 2017 22:49:15 +0100 Subject: [PATCH 02/14] change numbers --- src/recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index 7e0d4dde..fb452561 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -814,7 +814,7 @@ end end library = clibrary(cl.args[1]) - z = sqrt.((1:20)*(1:15)') + z = sqrt.((1:15)*(1:20)') seriestype := :heatmap ticks := nothing From d4b7bfbe1dab2d6705d7ce5b709848fde6f2f05f Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Wed, 22 Feb 2017 11:48:37 +0100 Subject: [PATCH 03/14] Added a recipe to show a single gradient --- src/recipes.jl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index fb452561..152752a3 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -810,7 +810,7 @@ end @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") + error("showlibrary takes the name of a color library as a Symbol") end library = clibrary(cl.args[1]) @@ -832,3 +832,17 @@ end 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 := grad.args[1] + z +end From 28b026c9adebfbca231fc310eabb71e3c4aab7ee Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Wed, 22 Feb 2017 11:49:31 +0100 Subject: [PATCH 04/14] replaced boxes with symmetrical squares --- src/recipes.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 152752a3..60f5997f 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -814,7 +814,7 @@ end end library = clibrary(cl.args[1]) - z = sqrt.((1:15)*(1:20)') + z = (1:20).+(1:20)' seriestype := :heatmap ticks := nothing @@ -838,7 +838,7 @@ end 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)') + z = (1:20).+(1:20)' seriestype := :heatmap ticks := nothing legend := false From b7536f129b3e3cf1876ed497c9d92dbc4098a16e Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Wed, 22 Feb 2017 11:52:54 +0100 Subject: [PATCH 05/14] Revert "replaced boxes with symmetrical squares" This reverts commit 28b026c9adebfbca231fc310eabb71e3c4aab7ee. --- src/recipes.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 60f5997f..152752a3 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -814,7 +814,7 @@ end end library = clibrary(cl.args[1]) - z = (1:20).+(1:20)' + z = sqrt.((1:15)*(1:20)') seriestype := :heatmap ticks := nothing @@ -838,7 +838,7 @@ end if !(length(grad.args) == 1 && isa(grad.args[1], Symbol)) error("showgradient takes the name of a color gradient as a Symbol") end - z = (1:20).+(1:20)' + z = sqrt.((1:15)*(1:20)') seriestype := :heatmap ticks := nothing legend := false From eab4cfdf2d4b4c5efe7e5daf285b0be2303da77e Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Sun, 26 Feb 2017 17:23:43 +0100 Subject: [PATCH 06/14] allow color libraries to be used in PlotThemes --- src/themes.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/themes.jl b/src/themes.jl index 3429585a..feb665d6 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -2,7 +2,8 @@ function theme(s::Symbol; kw...) # reset? if s == :none || s == :default - PlotUtils._default_gradient[] = :inferno + PlotUtils.set_clibrary(:matplotlib) + PlotUtils.cgraddefaults(:inferno) default(; bg = :white, bglegend = :match, @@ -23,7 +24,8 @@ function theme(s::Symbol; kw...) # update the default gradient and other defaults thm = PlotThemes._themes[s] if thm.gradient != nothing - PlotUtils._default_gradient[] = PlotThemes.gradient_name(s) + PlotUtils.set_clibrary(:plotthemes) + PlotUtils.cgraddefaults(PlotThemes.gradient_name(s)) end default(; bg = thm.bg_secondary, From 6c51982793c48d9dc24e4757a880ec0f2dbe566e Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Sun, 26 Feb 2017 20:43:04 +0100 Subject: [PATCH 07/14] fix theme default --- src/themes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/themes.jl b/src/themes.jl index feb665d6..442e67d0 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -25,7 +25,7 @@ function theme(s::Symbol; kw...) thm = PlotThemes._themes[s] if thm.gradient != nothing PlotUtils.set_clibrary(:plotthemes) - PlotUtils.cgraddefaults(PlotThemes.gradient_name(s)) + PlotUtils.cgraddefaults(default = PlotThemes.gradient_name(s)) end default(; bg = thm.bg_secondary, From 5465479e5772b60d4a19c6eae191f9fa3908b498 Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Mon, 27 Feb 2017 21:47:12 +0100 Subject: [PATCH 08/14] Put themes in Plots library --- src/themes.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/themes.jl b/src/themes.jl index 442e67d0..70ee50db 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -2,7 +2,7 @@ function theme(s::Symbol; kw...) # reset? if s == :none || s == :default - PlotUtils.set_clibrary(:matplotlib) + PlotUtils.set_clibrary(:Plots) PlotUtils.cgraddefaults(:inferno) default(; bg = :white, @@ -24,7 +24,7 @@ function theme(s::Symbol; kw...) # update the default gradient and other defaults thm = PlotThemes._themes[s] if thm.gradient != nothing - PlotUtils.set_clibrary(:plotthemes) + PlotUtils.set_clibrary(:Plots) PlotUtils.cgraddefaults(default = PlotThemes.gradient_name(s)) end default(; From 6b94bbac2d9031dd41b711794855b29f82ef16af Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Mon, 27 Feb 2017 21:52:22 +0100 Subject: [PATCH 09/14] updated function names --- src/themes.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/themes.jl b/src/themes.jl index 70ee50db..c069a251 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -2,8 +2,8 @@ function theme(s::Symbol; kw...) # reset? if s == :none || s == :default - PlotUtils.set_clibrary(:Plots) - PlotUtils.cgraddefaults(:inferno) + PlotUtils.clibrary(:Plots) + PlotUtils.default_cgrad(:inferno) default(; bg = :white, bglegend = :match, @@ -24,8 +24,8 @@ function theme(s::Symbol; kw...) # update the default gradient and other defaults thm = PlotThemes._themes[s] if thm.gradient != nothing - PlotUtils.set_clibrary(:Plots) - PlotUtils.cgraddefaults(default = PlotThemes.gradient_name(s)) + PlotUtils.clibrary(:Plots) + PlotUtils.default_cgrad(default = PlotThemes.gradient_name(s)) end default(; bg = thm.bg_secondary, From cad96e652f1634acbc52f768666bf1275864327c Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Mon, 27 Feb 2017 22:45:14 +0100 Subject: [PATCH 10/14] fix error on gr --- src/recipes.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index c4bf60c4..d30b763f 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -816,7 +816,7 @@ end error("showlibrary takes the name of a color library as a Symbol") end - library = clibrary(cl.args[1]) + library = PlotUtils.color_libraries[cl.args[1]] z = sqrt.((1:15)*(1:20)') seriestype := :heatmap @@ -828,8 +828,8 @@ end i = 0 for grad in keys(library.lib) @series begin - seriescolor := cgrad(grad, color_library = cl.args[1]) - title := grad + seriescolor := cgrad(grad, cl.args[1]) + title := string(grad) subplot := i += 1 z end From 41e56b1f2e4350ca9676995e18cde0d6e6d3e710 Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Tue, 28 Feb 2017 07:56:00 +0100 Subject: [PATCH 11/14] put PlotThemes in :misc --- src/themes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/themes.jl b/src/themes.jl index c069a251..702574e2 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -24,7 +24,7 @@ function theme(s::Symbol; kw...) # update the default gradient and other defaults thm = PlotThemes._themes[s] if thm.gradient != nothing - PlotUtils.clibrary(:Plots) + PlotUtils.clibrary(:hisc) PlotUtils.default_cgrad(default = PlotThemes.gradient_name(s)) end default(; From 1b468ba5d80348b232b3542d1a8837ab9e98a924 Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Tue, 28 Feb 2017 12:35:08 +0100 Subject: [PATCH 12/14] fix gr.text on showgradient --- src/recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index d30b763f..1089ea10 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -846,6 +846,6 @@ end ticks := nothing legend := false seriescolor := grad.args[1] - title := grad.args[1] + title := string(grad.args[1]) z end From 6f8881b610d3908e5413e4abc5101e2b8ed5009f Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Tue, 28 Feb 2017 12:43:06 +0100 Subject: [PATCH 13/14] set defaults to sequential --- src/themes.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/themes.jl b/src/themes.jl index 702574e2..e7a39d02 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -3,7 +3,7 @@ function theme(s::Symbol; kw...) # reset? if s == :none || s == :default PlotUtils.clibrary(:Plots) - PlotUtils.default_cgrad(:inferno) + PlotUtils.default_cgrad(default = :sequential, sequential = :inferno) default(; bg = :white, bglegend = :match, @@ -24,8 +24,8 @@ function theme(s::Symbol; kw...) # update the default gradient and other defaults thm = PlotThemes._themes[s] if thm.gradient != nothing - PlotUtils.clibrary(:hisc) - PlotUtils.default_cgrad(default = PlotThemes.gradient_name(s)) + PlotUtils.clibrary(:misc) + PlotUtils.default_cgrad(default = :sequential, sequential = PlotThemes.gradient_name(s)) end default(; bg = thm.bg_secondary, From 7e41a2f40d6aeff6f086faa510f2e48308d1ec18 Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Wed, 1 Mar 2017 22:18:34 +0100 Subject: [PATCH 14/14] sort colors --- src/recipes.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 1089ea10..3fa7a46e 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -823,10 +823,10 @@ end ticks := nothing legend := false - layout := length(library.lib) + layout --> length(library.lib) i = 0 - for grad in keys(library.lib) + for grad in sort(collect(keys(library.lib))) @series begin seriescolor := cgrad(grad, cl.args[1]) title := string(grad)