Skip to content

Feature: Added setter/getter methods for missing kwargs in Figure.__init__ #29638

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""
`matplotlib.figure` implements the following classes:

Expand Down Expand Up @@ -2648,6 +2648,19 @@
if not self.canvas.widgetlock.locked():
super().pick(mouseevent)

def set_figsize(self, _figsize):
self.set_size_inches(_figsize, forward=True)

Check warning on line 2652 in lib/matplotlib/figure.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/figure.py#L2652

Added line #L2652 was not covered by tests

def get_figsize(self):
return self.get_size_inches

Check failure on line 2656 in lib/matplotlib/figure.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 W293 blank line contains whitespace Raw Output: ./lib/matplotlib/figure.py:2656:1: W293 blank line contains whitespace
def set_subplotpars(self, _subplotpars):
'''self.subplotpars = _subplotpars

Check failure on line 2658 in lib/matplotlib/figure.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 D209 Multi-line docstring closing quotes should be on a separate line Raw Output: ./lib/matplotlib/figure.py:2658:1: D209 Multi-line docstring closing quotes should be on a separate line

Check failure on line 2658 in lib/matplotlib/figure.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 D213 Multi-line docstring summary should start at the second line Raw Output: ./lib/matplotlib/figure.py:2658:1: D213 Multi-line docstring summary should start at the second line

Check failure on line 2658 in lib/matplotlib/figure.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 D300 Use """triple double quotes""" Raw Output: ./lib/matplotlib/figure.py:2658:1: D300 Use """triple double quotes"""
self.subplots_adjust(self.subplotpars)'''

def get_subplotpars(self):
return self.subplotpars

Check warning on line 2662 in lib/matplotlib/figure.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/figure.py#L2662

Added line #L2662 was not covered by tests

def _check_layout_engines_compat(self, old, new):
"""
Helper for set_layout engine
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from matplotlib.axes import Axes
from matplotlib.backend_bases import KeyEvent, MouseEvent
from matplotlib.figure import Figure, FigureBase
from matplotlib.figure import SubplotParams

Check failure on line 20 in lib/matplotlib/tests/test_figure.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 F401 'matplotlib.figure.SubplotParams' imported but unused Raw Output: ./lib/matplotlib/tests/test_figure.py:20:1: F401 'matplotlib.figure.SubplotParams' imported but unused
from matplotlib.layout_engine import (ConstrainedLayoutEngine,
TightLayoutEngine,
PlaceHolderLayoutEngine)
Expand Down Expand Up @@ -1819,3 +1820,11 @@
sfig2.stale = True
assert sfig1.stale
assert fig.stale

def test_figsize_getter_setter():

Check failure on line 1824 in lib/matplotlib/tests/test_figure.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 E302 expected 2 blank lines, found 1 Raw Output: ./lib/matplotlib/tests/test_figure.py:1824:1: E302 expected 2 blank lines, found 1
fig = plt.figure()
test_size_get = fig.get_figsize()
assert len(test_size_get) == 2

fig.set_figsize((5, 5))
assert fig.get_figsize() == (5, 5)

Check failure on line 1830 in lib/matplotlib/tests/test_figure.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] reported by reviewdog 🐶 W292 no newline at end of file Raw Output: ./lib/matplotlib/tests/test_figure.py:1830:39: W292 no newline at end of file

Check warning on line 1830 in lib/matplotlib/tests/test_figure.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/tests/test_figure.py#L1829-L1830

Added lines #L1829 - L1830 were not covered by tests
Loading