Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e12db8d

Browse files
authored
Add get/set methods for DPI in SubFigure
This fixes the following error: matplotlib\lib\text.py line 1489, dop = self.figure.get_dpi()/72. AttributeError: 'SubFigure' object has no attribute 'get_dpi'. Effect: in v3.5.2 it is not possible to save a figure with a subfigure to a PDF.
1 parent 37cf8e4 commit e12db8d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/matplotlib/figure.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,6 +2045,21 @@ def dpi(self):
20452045
@dpi.setter
20462046
def dpi(self, value):
20472047
self._parent.dpi = value
2048+
2049+
def get_dpi(self):
2050+
"""Return the resolution of the parent figure in dots-per-inch as a float."""
2051+
return self._parent.dpi
2052+
2053+
def set_dpi(self, val):
2054+
"""
2055+
Set the resolution of parent figure in dots-per-inch.
2056+
2057+
Parameters
2058+
----------
2059+
val : float
2060+
"""
2061+
self._parent.dpi = val
2062+
self.stale = True
20482063

20492064
def _get_renderer(self):
20502065
return self._parent._get_renderer()

0 commit comments

Comments
 (0)