Skip to content

ENH: pass extra kwargs in FigureBase, SubFigure, Figure to set #20115

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

Merged
merged 1 commit into from
Aug 6, 2021

Conversation

tacaswell
Copy link
Member

PR Summary

Consistent with other artists and allows properties controlled by set_XYZ to
be set at init time.

Discovered this while working on mpl-gui

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).

@tacaswell tacaswell added this to the v3.5.0 milestone Apr 29, 2021
@QuLogic QuLogic changed the title ENH: pass extra kwrags in FigureBase, SubFigure, Figure to set ENH: pass extra kwargs in FigureBase, SubFigure, Figure to set Apr 29, 2021
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Seems useful!

@jklymak jklymak marked this pull request as draft May 10, 2021 20:51
@tacaswell tacaswell marked this pull request as ready for review August 5, 2021 17:46
@tacaswell tacaswell marked this pull request as draft August 5, 2021 17:48
@tacaswell tacaswell marked this pull request as ready for review August 5, 2021 17:56
Consistent with other artists and allows properties controlled by `set_XYZ` to
be set at init time.

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@tacaswell
Copy link
Member Author

Renders as
image

which has some styling issues, but ...

@timhoffm timhoffm merged commit d29056c into matplotlib:master Aug 6, 2021
@tacaswell tacaswell deleted the enh_figure_kwargs branch August 6, 2021 16:47
@jklymak
Copy link
Member

jklymak commented Dec 21, 2021

This has the unfortunate side effect of putting set_constrained_layout_pads in the list of things that can be set, despite the fact that it requires more than one kwarg. Is there a way to exclude some set_* methods from this?

@anntzer
Copy link
Contributor

anntzer commented Dec 21, 2021

ArtistInspector.get_setters currently just removes methods with len(inspect.signature(func).parameters) < 2, but we could add a get_setters_for_set (name up to bikeshedding) that checks whether inspect.signature(func).bind(None) (i.e., passing a single positional argument) succeeds, and only keeps these setters. Probably worth opening a separate issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants