File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -2107,21 +2107,28 @@ def _set_device_pixel_ratio(self, ratio):
2107
2107
self ._device_pixel_ratio = ratio
2108
2108
return True
2109
2109
2110
- def get_width_height (self ):
2110
+ def get_width_height (self , * , physical = False ):
2111
2111
"""
2112
2112
Return the figure width and height in integral points or pixels.
2113
2113
2114
2114
When the figure is used on High DPI screens (and the backend supports
2115
2115
it), the truncation to integers occurs after scaling by the device
2116
2116
pixel ratio.
2117
2117
2118
+ Parameters
2119
+ ----------
2120
+ physical : bool, default: False
2121
+ Whether to return true physical pixels or logical pixels. Physical
2122
+ pixels may be used by backends that support HiDPI, but still
2123
+ configure the canvas using its actual size.
2124
+
2118
2125
Returns
2119
2126
-------
2120
2127
width, height : int
2121
2128
The size of the figure, in points or pixels, depending on the
2122
2129
backend.
2123
2130
"""
2124
- return tuple (int (size / self .device_pixel_ratio )
2131
+ return tuple (int (size / ( 1 if physical else self .device_pixel_ratio ) )
2125
2132
for size in self .figure .bbox .max )
2126
2133
2127
2134
@classmethod
You can’t perform that action at this time.
0 commit comments