From 8c6eb34d91b515788bd4f2f837cf322f988c406c Mon Sep 17 00:00:00 2001 From: Grant Bruer Date: Mon, 1 Jul 2024 10:29:47 -0400 Subject: [PATCH 1/2] Use linestyle for Poly and Density legend elements --- src/makielayout/blocks/legend.jl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/makielayout/blocks/legend.jl b/src/makielayout/blocks/legend.jl index c4b7e34af29..96b2a376f59 100644 --- a/src/makielayout/blocks/legend.jl +++ b/src/makielayout/blocks/legend.jl @@ -300,7 +300,8 @@ function legendelement_plots!(scene, element::PolyElement, bbox::Observable{Rect 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 @@ -437,7 +438,7 @@ function legendelements(plot::Scatter, legend) )] end -function legendelements(plot::Union{Poly, Violin, BoxPlot, CrossBar, Density}, legend) +function legendelements(plot::Union{Violin, BoxPlot, CrossBar}, legend) color = extract_color(plot, legend[:polycolor]) LegendElement[PolyElement( color = color, @@ -462,6 +463,19 @@ function legendelements(plot::Band, legend) )] 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} From 8054a37f4d9dea02253b07c2f5df1660da14eb63 Mon Sep 17 00:00:00 2001 From: Grant Bruer Date: Fri, 26 Jul 2024 10:14:31 -0400 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 523c161707b..181f9149162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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).