Find same list of Artists that `Axes.legend()` finds

If one calls Axes.legend() with only strings (legend labels), then it automatically finds Artists and labels them for the legend. I have a situation where I want to throw away a couple of those Artists and show only some of them in the legend (for example I have a case where it finds 5 Artists but I only want to “legendize” only 3 of them).

I was thinking a good way for me to do this might be to find the same 5 Artists that the legend call finds, and then choose the three that I want and use the version of Axes.legend() where I pass in both the set of Artist handles and the legend labels.

Any suggestions?


Do you really just want to do this post-facto, rather than specifying label='foo' to the artists when you create them? Do you know the order of the artists is the legend? If so, you can just pass an underscore as the label to the unwanted elements: "_not wanted".

1 Like

Jody, Thank you! :+1: :slightly_smiling_face: :blush: