-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Getters setters #25901
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
Open
dutta712
wants to merge
8
commits into
matplotlib:main
Choose a base branch
from
dutta712:getters-setters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+111
−0
Open
Getters setters #25901
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5918332
added getters and setters subplotparams for figure
garveyz2 6b995ea
Added setter/getters for Figure for issue #24617
dutta712 965305b
initial fixes
dutta712 1c84734
Merge branch 'matplotlib:main' into getters-setters
dutta712 dcabceb
Merge branch 'matplotlib:main' into getters-setters
dutta712 67f3846
Fixed typo and removed whitespaces from blank lines
dutta712 49e2013
Added tests
dutta712 4e43c51
added stubs for getters/setters subplotparams
dutta712 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1201,6 +1201,67 @@ | |
self.stale = True | ||
return text | ||
|
||
def set_subplotparams(self, subplotparams={}): | ||
""" | ||
Set the subplot layout parameters. | ||
|
||
Accepts either a `.SubplotParams` object, from which the relevant | ||
parameters are copied, or a dictionary of subplot layout parameters. | ||
If a dictionary is provided, this function is a convenience wrapper for | ||
`matplotlib.figure.Figure.subplots_adjust` | ||
|
||
Parameters | ||
---------- | ||
subplotparams : `~matplotlib.figure.SubplotParams` or dict with keys | ||
"left", "bottom", "right", 'top", "wspace", "hspace"] , optional | ||
SubplotParams object to copy new subplot parameters from, or a dict | ||
of SubplotParams constructor arguments. | ||
By default, an empty dictionary is passed, which maintains the | ||
current state of the figure's `.SubplotParams` | ||
|
||
See Also | ||
-------- | ||
QuLogic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
matplotlib.figure.Figure.subplots_adjust | ||
matplotlib.figure.Figure.get_subplotparams | ||
""" | ||
|
||
subplotparams_args = ["left", "bottom", "right", | ||
"top", "wspace", "hspace"] | ||
kwargs = {} | ||
if isinstance(subplotparams, SubplotParams): | ||
for key in subplotparams_args: | ||
kwargs[key] = getattr(subplotparams, key) | ||
elif isinstance(subplotparams, dict): | ||
for key in subplotparams.keys(): | ||
if key in subplotparams_args: | ||
kwargs[key] = subplotparams[key] | ||
else: | ||
_api.warn_external( | ||
f"'{key}' is not a valid key for set_subplotparams;" | ||
" this key was ignored.") | ||
else: | ||
raise TypeError( | ||
"subplotparams must be a dictionary of keyword-argument pairs or" | ||
" an instance of SubplotParams()") | ||
if kwargs == {}: | ||
self.set_subplotparams(self.get_subplotparams()) | ||
self.subplots_adjust(**kwargs) | ||
|
||
def get_subplotparams(self): | ||
""" | ||
Return the `.SubplotParams` object associated with the Figure. | ||
|
||
Returns | ||
------- | ||
QuLogic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`.SubplotParams` | ||
|
||
See Also | ||
-------- | ||
matplotlib.figure.Figure.subplots_adjust | ||
matplotlib.figure.Figure.get_subplotparams | ||
""" | ||
return self.subplotpars | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is failing because of this line, I don't think you've defined what subplotpars is. |
||
|
||
@_docstring.dedent_interpd | ||
def colorbar( | ||
self, mappable, cax=None, ax=None, use_gridspec=True, **kwargs): | ||
|
@@ -2346,6 +2407,10 @@ | |
|
||
|
||
@_docstring.interpd | ||
@_api.define_aliases({ | ||
"size_inches": ["figsize"], | ||
"layout_engine": ["layout"], | ||
}) | ||
class Figure(FigureBase): | ||
""" | ||
The top level container for all the plot elements. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.