From 8c6eb34d91b515788bd4f2f837cf322f988c406c Mon Sep 17 00:00:00 2001 From: Grant Bruer Date: Mon, 1 Jul 2024 10:29:47 -0400 Subject: [PATCH] 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}