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

Use linestyle for Poly and Density legend elements #4000

Merged
merged 2 commits into from
Jul 26, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Use linestyle for Poly and Density legend elements [#4000](https://github.com/MakieOrg/Makie.jl/pull/4000).
- Bring back interpolation attribute for surface [#4056](https://github.com/MakieOrg/Makie.jl/pull/4056).
- Improved accuracy of framerate settings in GLMakie [#3954](https://github.com/MakieOrg/Makie.jl/pull/3954)
- Fix label_formatter being called twice in barplot [#4046](https://github.com/MakieOrg/Makie.jl/pull/4046).
Expand Down
18 changes: 16 additions & 2 deletions src/makielayout/blocks/legend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@
points = lift((bb, fp) -> fractionpoint.(Ref(bb), fp), scene, bbox, fracpoints)
pol = poly!(scene, points, strokewidth = attrs.polystrokewidth, color = attrs.polycolor,
strokecolor = attrs.polystrokecolor, inspectable = false,
colormap = attrs.polycolormap, colorrange = attrs.polycolorrange)
colormap = attrs.polycolormap, colorrange = attrs.polycolorrange,
linestyle = attrs.linestyle)

return [pol]
end
Expand Down Expand Up @@ -437,7 +438,7 @@
)]
end

function legendelements(plot::Union{Poly, Violin, BoxPlot, CrossBar, Density}, legend)
function legendelements(plot::Union{Violin, BoxPlot, CrossBar}, legend)

Check warning on line 441 in src/makielayout/blocks/legend.jl

View check run for this annotation

Codecov / codecov/patch

src/makielayout/blocks/legend.jl#L441

Added line #L441 was not covered by tests
color = extract_color(plot, legend[:polycolor])
LegendElement[PolyElement(
color = color,
Expand All @@ -462,6 +463,19 @@
)]
end

function legendelements(plot::Union{Poly, Density}, legend)
color = Makie.extract_color(plot, legend[:polycolor])
LegendElement[Makie.PolyElement(
color = color,
strokecolor = Makie.choose_scalar(plot.strokecolor, legend[:polystrokecolor]),
strokewidth = Makie.choose_scalar(plot.strokewidth, legend[:polystrokewidth]),
colormap = plot.colormap,
colorrange = plot.colorrange,
linestyle = plot.linestyle,
)]
end


# if there is no specific overload available, we go through the child plots and just stack
# those together as a simple fallback
function legendelements(plot, legend)::Vector{LegendElement}
Expand Down
Loading