Resolving: Add setter/getter methods for all keyword parameters to Figure.__init__ (Issue: #24617) by zaheerhashmi · Pull Request #27531 · matplotlib/matplotlib · GitHub
Skip to content

Resolving: Add setter/getter methods for all keyword parameters to Figure.__init__ (Issue: #24617) - #27531

Closed
zaheerhashmi wants to merge 9 commits into
matplotlib:mainfrom
zaheerhashmi:zaheerhashmi_getter_setter_figure
Closed

zaheerhashmi wants to merge 9 commits into
matplotlib:mainfrom
zaheerhashmi:zaheerhashmi_getter_setter_figure

Conversation

@zaheerhashmi

Copy link
Copy Markdown

PR summary

This PR adds aliasing for layout, figsize and adds getter and setter methods for subplotparams.
It resolves #24617. The PR utilized #21549 and #25901.

PR checklist

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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.

@zaheerhashmi
zaheerhashmi marked this pull request as draft December 17, 2023 01:26
Comment thread lib/matplotlib/figure.py

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.

Why did this need to come back?

Comment thread lib/matplotlib/figure.py
ax._set_position(ax.get_subplotspec().get_position(self))
self.stale = True

def set_subplotpars(self, subplotparams={}):

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.

Default values should not be mutable objects like a dictionary. You should set it to None, and then check that in the function.

Suggested change
def set_subplotpars(self, subplotparams={}):
def set_subplotpars(self, subplotparams=None):

Comment thread lib/matplotlib/figure.py
Comment on lines +1389 to +1392
else:
_api.warn_external(
f"'{key}' is not a valid key for set_subplotpars;"
" this key was ignored.")

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.

As a new function, this should be an error, not a warning.

Comment thread lib/matplotlib/figure.py
Comment on lines +1397 to +1398
if kwargs == {}:
self.set_subplotpars(self.get_subplotpars())

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.

I don't understand what this is doing?

@melissawm melissawm added the status: needs comment/discussion needs consensus on next step label Mar 6, 2026
@melissawm melissawm moved this to Needs decision in First Time Contributors Mar 6, 2026
@melissawm

Copy link
Copy Markdown
Member

@melissawm melissawm closed this Mar 27, 2026
@github-project-automation github-project-automation Bot moved this from Needs decision 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

Labels

status: needs comment/discussion needs consensus on next step

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