8000 Merge pull request #23276 from scottjones03/patch-1 · matplotlib/matplotlib@d417b98 · GitHub
[go: up one dir, main page]

Skip to content

Commit d417b98

Browse files
authored
Merge pull request #23276 from scottjones03/patch-1
MNT: Add get/set methods for DPI in SubFigure
2 parents dabae3a + 0e63d04 commit d417b98

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lib/matplotlib/figure.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,23 @@ def dpi(self):
20462046
def dpi(self, value):
20472047
self._parent.dpi = value
20482048

2049+
def get_dpi(self):
2050+
"""
2051+
Return the resolution of the parent figure in dots-per-inch as a float.
2052+
"""
2053+
return self._parent.dpi
2054+
2055+
def set_dpi(self, val):
2056+
"""
2057+
Set the resolution of parent figure in dots-per-inch.
2058+
2059+
Parameters
2060+
----------
2061+
val : float
2062+
"""
2063+
self._parent.dpi = val
2064+
self.stale = True
2065+
20492066
def _get_renderer(self):
20502067
return self._parent._get_renderer()
20512068

lib/matplotlib/tests/test_figure.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,16 @@ def test_subfigure_tightbbox():
11091109
8.0)
11101110

11111111

1112+
def test_subfigure_dpi():
1113+
fig = plt.figure(dpi=100)
1114+
sub_fig = fig.subfigures()
1115+
assert sub_fig.get_dpi() == fig.get_dpi()
1116+
1117+
sub_fig.set_dpi(200)
1118+
assert sub_fig.get_dpi() == 200
1119+
assert fig.get_dpi() == 200
1120+
1121+
11121122
@image_comparison(['test_subfigure_ss.png'], style='mpl20',
11131123
savefig_kwarg={'facecolor': 'teal'})
11141124
def test_subfigure_ss():

0 commit comments

Comments
 (0)
0