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