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

Class GridSpec

lib/matplotlib/gridspec.py:304–468  ·  view source on GitHub ↗

A grid layout to place subplots within a figure. The location of the grid cells is determined in a similar way to `.SubplotParams` using *left*, *right*, *top*, *bottom*, *wspace* and *hspace*. Indexing a GridSpec instance returns a `.SubplotSpec`.

Source from the content-addressed store, hash-verified

302
303
304class GridSpec(GridSpecBase):
305 """
306 A grid layout to place subplots within a figure.
307
308 The location of the grid cells is determined in a similar way to
309 `.SubplotParams` using *left*, *right*, *top*, *bottom*, *wspace*
310 and *hspace*.
311
312 Indexing a GridSpec instance returns a `.SubplotSpec`.
313 """
314 def __init__(self, nrows, ncols, figure=None,
315 left=None, bottom=None, right=None, top=None,
316 wspace=None, hspace=None,
317 width_ratios=None, height_ratios=None):
318 """
319 Parameters
320 ----------
321 nrows, ncols : int
322 The number of rows and columns of the grid.
323
324 figure : `.Figure`, optional
325 Only used for constrained layout to create a proper layoutgrid.
326
327 left, right, top, bottom : float, optional
328 Extent of the subplots as a fraction of figure width or height.
329 Left cannot be larger than right, and bottom cannot be larger than
330 top. If not given, the values will be inferred from a figure or
331 rcParams at draw time. See also `GridSpec.get_subplot_params`.
332
333 wspace : float, optional
334 The amount of width reserved for space between subplots,
335 expressed as a fraction of the average axis width.
336 If not given, the values will be inferred from a figure or
337 rcParams when necessary. See also `GridSpec.get_subplot_params`.
338
339 hspace : float, optional
340 The amount of height reserved for space between subplots,
341 expressed as a fraction of the average axis height.
342 If not given, the values will be inferred from a figure or
343 rcParams when necessary. See also `GridSpec.get_subplot_params`.
344
345 width_ratios : array-like of length *ncols*, optional
346 Defines the relative widths of the columns. Each column gets a
347 relative width of ``width_ratios[i] / sum(width_ratios)``.
348 If not given, all columns will have the same width.
349
350 height_ratios : array-like of length *nrows*, optional
351 Defines the relative heights of the rows. Each row gets a
352 relative height of ``height_ratios[i] / sum(height_ratios)``.
353 If not given, all rows will have the same height.
354
355 """
356 self.left = left
357 self.bottom = bottom
358 self.right = right
359 self.top = top
360 self.wspace = wspace
361 self.hspace = hspace

Callers 8

add_gridspecMethod · 0.90
subfiguresMethod · 0.90
test_wrapFunction · 0.90
_from_subplot_argsMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_wrapFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…