Add possibility to collect legend entries from multiple axes#5500
Add possibility to collect legend entries from multiple axes#5500jusack wants to merge 5 commits intoMakieOrg:masterfrom
Conversation
jkrumbiegel
left a comment
There was a problem hiding this comment.
One of the tests is really enough, given the super simple mechanism not much is gained by piping many different plot types through. Rather, it could be tested once that the legend actually has the two expected entries.
|
Thank you for the comment and looking at the PR. I have adjusted the test. However I am not sure if I the indexing into all the layers is the best way to get to the legend content. Is there an easier way to achieve what I was trying? |
| If `unique` is `true`, all plot objects with the same plot type and label will be reduced to one occurrence. | ||
| """ | ||
| function Legend(fig_or_scene, axis::Union{Axis, Axis3, Scene, LScene}, title = nothing; merge = false, unique = false, kwargs...) | ||
| function Legend(fig_or_scene, axis::Union{Axis, Axis3, Scene, LScene, AbstractVector{<:Union{Axis, Axis3, Scene, LScene}}}, title = nothing; merge = false, unique = false, kwargs...) |
There was a problem hiding this comment.
Docstring should be updated here
There was a problem hiding this comment.
This isn't really related to the pr, but shouldn't the types here be Union{AbstractAxis, Scene} so this can work with other axis types more easily? Like GeoMakie.GeoAxis or PolarAxis? (And maybe we should also have get_plots(ax::AbstractAxis) = ax.scene?)
docs/src/reference/blocks/legend.md
Outdated
| If `merge` is `true`, all plot objects with the same label will be layered on top of each other into one legend entry. | ||
| If `unique` is `true`, all plot objects with the same plot type and label will be reduced to one occurrence. | ||
|
|
||
| To create a joint legend for multiple axes it is also possible to pass a `Vector` of axis objects. |
There was a problem hiding this comment.
Would be good to add a simple visual example here, maybe one that uses merge too
|
two more comments got stuck in the pipeline, I've submitted them again now. The indexing in the test is fine, using internals internally is ok :) |
|
I would like share my view: |
Description
I added a convenient way to gather legend entries from multiple axes, i.e.
will produce a joint legend for both axes.

The main reason why this is relevant for me is that the interactivity is then linked as well:

Type of change
Checklist