MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / set_size_inches

Method set_size_inches

lib/matplotlib/figure.py:3129–3173  ·  view source on GitHub ↗

Set the figure size in inches. Call signatures:: fig.set_size_inches(w, h) # OR fig.set_size_inches((w, h)) Parameters ---------- w : (float, float) or float Width and height in inches (if height not specified as a se

(self, w, h=None, forward=True)

Source from the content-addressed store, hash-verified

3127 return im
3128
3129 def set_size_inches(self, w, h=None, forward=True):
3130 """
3131 Set the figure size in inches.
3132
3133 Call signatures::
3134
3135 fig.set_size_inches(w, h) # OR
3136 fig.set_size_inches((w, h))
3137
3138 Parameters
3139 ----------
3140 w : (float, float) or float
3141 Width and height in inches (if height not specified as a separate
3142 argument) or width.
3143 h : float
3144 Height in inches.
3145 forward : bool, default: True
3146 If ``True``, the canvas size is automatically updated, e.g.,
3147 you can resize the figure window from the shell.
3148
3149 See Also
3150 --------
3151 matplotlib.figure.Figure.get_size_inches
3152 matplotlib.figure.Figure.set_figwidth
3153 matplotlib.figure.Figure.set_figheight
3154
3155 Notes
3156 -----
3157 To transform from pixels to inches divide by `Figure.dpi`.
3158 """
3159 if h is None: # Got called with a single pair as argument.
3160 w, h = w
3161 if w is None or h is None:
3162 raise ValueError(
3163 "Figure.set_size_inches does not accept None; provide both "
3164 "width and height explicitly")
3165 size = np.array([w, h])
3166 if not np.isfinite(size).all() or (size < 0).any():
3167 raise ValueError(f'figure size must be positive finite not {size}')
3168 self.bbox_inches.p1 = size
3169 if forward:
3170 manager = self.canvas.manager
3171 if manager is not None:
3172 manager.resize(*(size * self.dpi).astype(int))
3173 self.stale = True
3174
3175 def get_size_inches(self):
3176 """

Callers 15

_set_dpiMethod · 0.95
figimageMethod · 0.95
set_figwidthMethod · 0.95
set_figheightMethod · 0.95
test_fill_facecolorFunction · 0.80
_adjust_frame_sizeMethod · 0.80
grab_frameMethod · 0.80
handle_resizeMethod · 0.80
size_allocateMethod · 0.80
configure_eventMethod · 0.80
resizeMethod · 0.80

Calls 1

resizeMethod · 0.45

Tested by 15

test_fill_facecolorFunction · 0.64
test_completeFunction · 0.64
test_grabframeFunction · 0.64
test_marker_clippingFunction · 0.64
test_double_resizeFunction · 0.64
test_secondary_resizeFunction · 0.64
test_set_fig_sizeFunction · 0.64