Skip to content

Conversation

@MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Feb 25, 2021

So, in #27808 , leg.legendHandles was replaced with ax.get_legend_handles_labels()[0] in order to preserve marker info.

However, ax.get_legend_handles_labels()[0] may contain extra elements which aren't (yet) visible, which means we may end up at

ax.legend(handles, labels, loc="best", title=title)

with

(Pdb) handles
[<matplotlib.lines.Line2D object at 0x7f0938a37430>, <ErrorbarContainer object of 3 artists>, <matplotlib.lines.Line2D object at 0x7f0938a37430>]
(Pdb) labels
['orange', 'blue']

This causes the permuting noted in #39522

Ideally, there would be a way to get leg.legendHandles in a way that preserves the marker info. However, I can't find a way to do that - have asked on the matplotlib discourse. Also, the current test doesn't quite work (as it passes on master too). I'm working on finding a satisfactory solution


On master:

image

On this branch:

image


cc @charlesdong1991 in case you have comments / suggestions

@MarcoGorelli
Copy link
Member Author

closing as I'm not happy with this solution - will get back to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant