Skip to content

fixed #24617 bug - Added subplot params and figsize getter setter methods to Figure.__init__ with tests #29116

Closed
Thanushri16 wants to merge 5 commits intomatplotlib:mainfrom
Thanushri16:bugfix_24617_25091
Closed

fixed #24617 bug - Added subplot params and figsize getter setter methods to Figure.__init__ with tests #29116
Thanushri16 wants to merge 5 commits intomatplotlib:mainfrom
Thanushri16:bugfix_24617_25091

Conversation

@Thanushri16
Copy link
Copy Markdown

PR summary
This is the first PR I am proposing and this PR fixes #24617 - [ENH]: Add setter/getter methods for all keyword parameters to Figure.init
Few of the arguments passed to Figure.init did not have matching get_{kwarg}/set_{kwarg} methods on Figure (Bug #24617).
This PR focuses on adding getter/setter methods and test coverage for the following:

  • figsize (which wraps around get_size_inches and set_size_inches)
  • subplotparams

What problem does this PR solve?
Two of the properties/parameters of Figure class didn't have getter/setter methods implemented - figsize, subplotparams. Without these getter/setter methods, use of the properties in the Figure class is inconsistent and neither does the class provide a way to set properties for these two attributes without the getter/setter methods.

Relevant PRs (Both of these PRs have failing tests and failing checks for PR reviews):

  1. PR #25901 - This PR focuses on getter/setter methods to resolve Bug [ENH]: Add setter/getter methods for all keyword parameters to Figure.__init__ #24617 . The PR encounters AttributeError: 'Figure' object has no attribute 'get_subplotpars' that is not resolved and also has failing PR checks.
  2. PR #28936 - This PR resolves the AttributeError issues in PR #25901. However, the PR still had some failing test cases in pytest and has some failing PR checks.

PR checklist:

##Review
Since, this is my first contribution in the open source, I would like to know the feedback and tips to improve my contributions.

…n getter setter for subplot param and figsize
Copy link
Copy Markdown

@github-actions github-actions bot 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 us on gitter for real-time discussion.

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

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

self.set_subplotparams(self.get_subplotparams())
self.subplots_adjust(**kwargs)

def get_subplotparams(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This method is not run by the tests because you replaced it in the Figure subclass, so only the subclass one gets run by your new test. I'm not too familiar with subplotparams but, as far as I can see, they only exist on a Figure and not on a SubFigure so both these methods could go directly on the Figure class.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@rcomer Fixed the above inheritance issue. Thanks for pointing it out. I've moved the definitions to Figure and all the pytest cases passed locally. Could you please review my failing pytest macOS tests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those MacOS ones are often flakey. I’ve re-started them to see if they do better this time 🤞

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the documentation failure I think you just need to add your new methods to an appropriate section here, to make them show up in the docs:
https://github.com/matplotlib/matplotlib/blob/main/doc/api/figure_api.rst

@melissawm
Copy link
Copy Markdown
Member

We discussed issue #24617 in the weekly meeting yesterday, and the general opinion is that this issue needs refinement before it's actually actionable.

For this reason, I will close all related open issues for now. This does not mean you can't open another PR in the future or that your solution is necessarily innapropriate, but this will help us focus our efforts.

Thank you for your contribution and hope to see you around!

@melissawm melissawm closed this Mar 27, 2026
@github-project-automation github-project-automation bot moved this from Needs review to Done in First Time Contributors Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

[ENH]: Add setter/getter methods for all keyword parameters to Figure.__init__

3 participants