From 52e27ab4536f78b3bcf4e14b98c8a9ac2c2cb656 Mon Sep 17 00:00:00 2001 From: JonasIsensee Date: Wed, 27 Sep 2023 12:36:08 +0000 Subject: [PATCH 1/3] replace bgcolor with backgroundcolor --- README.md | 2 +- ReferenceTests/src/tests/figures_and_makielayout.jl | 4 ++-- docs/reference/plots/datashader.md | 2 +- src/makielayout/blocks/legend.jl | 2 +- src/makielayout/types.jl | 2 +- src/themes/theme_black.jl | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 49c5a3ccaa1..b425927bfe1 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ with_theme(palette = (; patchcolor = cgrad(cmap, alpha=0.45))) do band!(x, sin.(x), approx .+= x .^ 5 / 120; label = L"n = 2") band!(x, sin.(x), approx .+= -x .^ 7 / 5040; label = L"n = 3") limits!(-3.8, 3.8, -1.5, 1.5) - axislegend(; position = :ct, bgcolor = (:white, 0.75), framecolor = :orange) + axislegend(; position = :ct, backgroundcolor = (:white, 0.75), framecolor = :orange) save("./assets/approxsin.png", fig, resolution = (800, 600)) fig end diff --git a/ReferenceTests/src/tests/figures_and_makielayout.jl b/ReferenceTests/src/tests/figures_and_makielayout.jl index eba9109bdd1..6a26f75c22d 100644 --- a/ReferenceTests/src/tests/figures_and_makielayout.jl +++ b/ReferenceTests/src/tests/figures_and_makielayout.jl @@ -116,8 +116,8 @@ end lines!(ax,( 1:10) .* i, label = "$i") end # To verify that RGB values differ across entries - axislegend(ax, position = :lt, patchcolor = :red, patchsize = (100, 100), bgcolor = :gray50); - Legend(f[1, 2], ax, patchcolor = :gray80, patchsize = (100, 100), bgcolor = :gray50); + axislegend(ax, position = :lt, patchcolor = :red, patchsize = (100, 100), backgroundcolor = :gray50); + Legend(f[1, 2], ax, patchcolor = :gray80, patchsize = (100, 100), backgroundcolor = :gray50); f end end diff --git a/docs/reference/plots/datashader.md b/docs/reference/plots/datashader.md index f8bde5f5414..b3086fa15f2 100644 --- a/docs/reference/plots/datashader.md +++ b/docs/reference/plots/datashader.md @@ -217,7 +217,7 @@ We can also re-use the previous NYC example for a categorical plot: hidedecorations!(ax) hidespines!(ax) # Create a styled legend - axislegend("Vendor ID"; titlecolor=:white, framecolor=:grey, polystrokewidth=2, polystrokecolor=(:white, 0.5), rowgap=10, bgcolor=:black, labelcolor=:white) + axislegend("Vendor ID"; titlecolor=:white, framecolor=:grey, polystrokewidth=2, polystrokecolor=(:white, 0.5), rowgap=10, backgroundcolor=:black, labelcolor=:white) display(f) end ``` diff --git a/src/makielayout/blocks/legend.jl b/src/makielayout/blocks/legend.jl index 8d995e774f6..f7ef078e1ac 100644 --- a/src/makielayout/blocks/legend.jl +++ b/src/makielayout/blocks/legend.jl @@ -21,7 +21,7 @@ function initialize_block!(leg::Legend, bg = poly!(scene, legendrect, - color = leg.bgcolor, strokewidth = leg.framewidth, visible = leg.framevisible, + color = leg.backgroundcolor, strokewidth = leg.framewidth, visible = leg.framevisible, strokecolor = leg.framecolor, inspectable = false) translate!(bg, 0, 0, -7) # bg behind patches but before content at 0 (legend is at +10) diff --git a/src/makielayout/types.jl b/src/makielayout/types.jl index 7f3595833e4..c721b797005 100644 --- a/src/makielayout/types.jl +++ b/src/makielayout/types.jl @@ -1188,7 +1188,7 @@ const EntryGroup = Tuple{Any, Vector{LegendEntry}} "The additional space between the legend and its suggested boundingbox." margin = (0f0, 0f0, 0f0, 0f0) "The background color of the legend." - bgcolor = :white + backgroundcolor = :white "The color of the legend border." framecolor = :black "The line width of the legend border." diff --git a/src/themes/theme_black.jl b/src/themes/theme_black.jl index 1f0b9965b59..3ee6e7fb23d 100644 --- a/src/themes/theme_black.jl +++ b/src/themes/theme_black.jl @@ -16,7 +16,7 @@ function theme_black() ), Legend = ( framecolor = :white, - bgcolor = :black, + backgroundcolor = :black, ), Axis3 = ( xgridcolor = RGBAf(1, 1, 1, 0.16), From 30b22544251d2cca5d78b14b118efe3161e88f0b Mon Sep 17 00:00:00 2001 From: JonasIsensee Date: Wed, 27 Sep 2023 13:02:54 +0000 Subject: [PATCH 2/3] make it a deprecation --- src/makielayout/blocks/legend.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/makielayout/blocks/legend.jl b/src/makielayout/blocks/legend.jl index f7ef078e1ac..f80c51059d0 100644 --- a/src/makielayout/blocks/legend.jl +++ b/src/makielayout/blocks/legend.jl @@ -19,9 +19,16 @@ function initialize_block!(leg::Legend, enlarge(la, -lm[1], -lm[2], -lm[3], -lm[4]) end + backgroundcolor = if haskey(leg, :bgcolor) + @warn("Keyword argument `bgcolor` is deprecated, use `backgroundcolor` instead.") + leg.bgcolor + else + leg.backgroundcolor + end + bg = poly!(scene, legendrect, - color = leg.backgroundcolor, strokewidth = leg.framewidth, visible = leg.framevisible, + color = backgroundcolor, strokewidth = leg.framewidth, visible = leg.framevisible, strokecolor = leg.framecolor, inspectable = false) translate!(bg, 0, 0, -7) # bg behind patches but before content at 0 (legend is at +10) From 25cbeb416a3938641ec3b285925638d50573c619 Mon Sep 17 00:00:00 2001 From: Jonas Isensee Date: Thu, 28 Sep 2023 18:31:34 +0200 Subject: [PATCH 3/3] need to keep bgcolor as attribute --- src/makielayout/blocks/legend.jl | 2 +- src/makielayout/types.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/makielayout/blocks/legend.jl b/src/makielayout/blocks/legend.jl index f80c51059d0..6f7492b476c 100644 --- a/src/makielayout/blocks/legend.jl +++ b/src/makielayout/blocks/legend.jl @@ -19,7 +19,7 @@ function initialize_block!(leg::Legend, enlarge(la, -lm[1], -lm[2], -lm[3], -lm[4]) end - backgroundcolor = if haskey(leg, :bgcolor) + backgroundcolor = if !isnothing(leg.bgcolor[]) @warn("Keyword argument `bgcolor` is deprecated, use `backgroundcolor` instead.") leg.bgcolor else diff --git a/src/makielayout/types.jl b/src/makielayout/types.jl index c721b797005..7bd6ec76437 100644 --- a/src/makielayout/types.jl +++ b/src/makielayout/types.jl @@ -1187,6 +1187,8 @@ const EntryGroup = Tuple{Any, Vector{LegendEntry}} padding = (10f0, 10f0, 8f0, 8f0) "The additional space between the legend and its suggested boundingbox." margin = (0f0, 0f0, 0f0, 0f0) + "The background color of the legend. DEPRECATED - use `backgroundcolor` instead." + bgcolor = nothing "The background color of the legend." backgroundcolor = :white "The color of the legend border."