Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Incorrect type annotation for legend handes? #26639

Closed
mwaskom opened this issue Aug 30, 2023 · 0 comments
Closed

[Bug]: Incorrect type annotation for legend handes? #26639

mwaskom opened this issue Aug 30, 2023 · 0 comments
Milestone

Comments

@mwaskom
Copy link

mwaskom commented Aug 30, 2023

Bug summary

The handles parameter for mpl.legend.Legend is typed as Iterable[Artist], but I believe that legend handles can also be artist tuples to produce a combo legend annotation?

Code for reproduction

# This works anyway

import matplotlib as mpl
import matplotlib.pyplot as plt

f, ax = plt.subplots()
h1 = mpl.lines.Line2D([], [])
h2 = mpl.patches.Patch(alpha=.2)
ax.legend(handles=[(h1, h2)], labels=["combo artist"])

Actual outcome

MyPy error when I pass a list of artist tuples to mpl.legend.Legend.

Expected outcome

I think this is valid matplotlib?

Additional information

Sorry the bug report template isn't the ideal format for this.

Operating system

No response

Matplotlib Version

3.8.0rc1

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

@QuLogic QuLogic added this to the v3.8.0 milestone Aug 30, 2023
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Aug 31, 2023
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Aug 31, 2023
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants