Skip to content

Commit

Permalink
Use linestyle for Poly and Density legend elements
Browse files Browse the repository at this point in the history
  • Loading branch information
gbruer15 committed Jul 26, 2024
1 parent b1e7bfd commit 8c6eb34
Showing 1 changed file with 16 additions and 2 deletions.
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 @@ 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
Expand Down Expand Up @@ -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,
Expand All @@ -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}
Expand Down

0 comments on commit 8c6eb34

Please sign in to comment.