Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace bgcolor with backgroundcolor in Legend #3261

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/plots/datashader.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
9 changes: 8 additions & 1 deletion src/makielayout/blocks/legend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ function initialize_block!(leg::Legend,
enlarge(la, -lm[1], -lm[2], -lm[3], -lm[4])
end

backgroundcolor = if !isnothing(leg.bgcolor[])
@warn("Keyword argument `bgcolor` is deprecated, use `backgroundcolor` instead.")
leg.bgcolor
else
leg.backgroundcolor
end

bg = poly!(scene,
legendrect,
color = leg.bgcolor, 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)

Expand Down
4 changes: 3 additions & 1 deletion src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,10 @@ 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."
bgcolor = :white
backgroundcolor = :white
"The color of the legend border."
framecolor = :black
"The line width of the legend border."
Expand Down
2 changes: 1 addition & 1 deletion src/themes/theme_black.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function theme_black()
),
Legend = (
framecolor = :white,
bgcolor = :black,
backgroundcolor = :black,
),
Axis3 = (
xgridcolor = RGBAf(1, 1, 1, 0.16),
Expand Down
Loading