Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add ability to toggle legend in the figure options dialog box#30128

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ritvi-alagusankar wants to merge3 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromritvi-alagusankar:add-ability-legend-toggle-figure-options

Conversation

ritvi-alagusankar
Copy link

@ritvi-alagusankarritvi-alagusankar commentedJun 2, 2025
edited
Loading

PR summary

Added the ability to toggle legend in the figure options dialog box, solving issue#11109. Changes in the PR:

  • Added a "Legend visible" checkbox to the figure options dialog box.
  • Implemented the callback to toggle legend visibility based on the value of the checkbox.

PR checklist

@ritvi-alagusankarritvi-alagusankar marked this pull request as ready for reviewJune 2, 2025 12:34
Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@ritvi-alagusankarritvi-alagusankar changed the titlefeat: add ability to toggle legend in the figure options dialog boxAdd ability to toggle legend in the figure options dialog boxJun 3, 2025
@ritvi-alagusankar
Copy link
Author

@rcomer gentle ping to help review this PR, this will be my first contribution to matplotlib. Please let me know if there are any changes to be made :)

@rcomer
Copy link
Member

I’m sorry but I am not currently available for reviewing. I also am not familiar with this part of the library so it is unlikely I will review it when I am available again.

@story645
Copy link
Member

@ritvi-alagusanka please add some tests for your code. You may wanna look at the tests for similar features as a model

@ritvi-alagusankar
Copy link
Author

ritvi-alagusankar commentedJul 1, 2025
edited
Loading

@story645@melissawm I have added a test case for this feature. Could you please help review this PR

@YQ157
Copy link

Hi, I noticed Codecov reported missing coverage on this PR.

Since I don’t have push access to the source branch, I opened a follow-up PR to add the missing tests:#30587.
It extends the test suite for the QtAgg figureoptions dialog (legend handling, mappables, etc.) to improve coverage.

This is actually my first open-source contribution — happy to start by helping here! 🎉
Maintainers may merge it directly or cherry-pick into this PR, whichever is preferred.

Thanks again for the original work!

@rcomer
Copy link
Member

Note that CodeCov failing is not necessarily a blocker to getting this PR merged.
https://matplotlib.org/devdocs/devel/development_workflow.html#automated-tests

@ritvi-alagusankar
Copy link
Author

2> Note that CodeCov failing is not necessarily a blocker to getting this PR merged.https://matplotlib.org/devdocs/devel/development_workflow.html#automated-tests

@rcomer Could you help review this PR :)

YQ157 reacted with eyes emoji

Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Overall, I'm sceptical that the matplotlib core library should invest further into configuration GUI. It's a rabbit hole. Also, all needed API is public and stable, so that such GUIs can be developed to arbitrary complexity by third parties; see e.g.https://pylustrator.readthedocs.io/en/latest/.

)
forname,axisinaxis_map.items()
]),
('Legend visible',axes.legend_isnotNone),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

AFAICS this does not work, because it does not cover the case of an existing legend withset_visible(False)

Comment on lines +261 to +263
# toggle legend visibility
ifaxes.legend_isnotNone:
axes.legend_.set_visible(legend_visible)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I have an issue with this:
Let's say, we don't have a legend, then the checkbox "Legend visible" is unchecked.
If the user checks the box, surpisingly nothing will happen since, we don't have a legend.

Either we would need to generate a legend (not so great beacuse we'd need to assume the defaults, equivalent to alegend() call), or we'd have to deactivate the checkbox if no legend is available (not sure whether that is possible with the generic dialog concept).

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

@timhoffmtimhoffmtimhoffm left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
Projects
Status: Needs review
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

ENH: Add legend toggle to figure options dialog box
5 participants
@ritvi-alagusankar@rcomer@story645@YQ157@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp