### Navigation

- index
- modules |
- next |
- previous |
- home|
- examples|
- tutorials|
- pyplot|
- docs »
- The Matplotlib API »
- gridspec »

# matplotlib.gridspec.GridSpec

class `matplotlib.gridspec.``GridSpec`(nrows, ncols, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None, width_ratios=None, height_ratios=None)

  A class that specifies the geometry of the grid that a subplot will be placed. The location of grid is determined by similar way as the SubplotParams.

  The number of rows and number of columns of the grid need to be set. Optionally, the subplot layout parameters (e.g., left, right, etc.) can be tuned.

## Examples using `matplotlib.gridspec.GridSpec`

Streamplot

Demo Tight Layout

Markevery Demo

Pie Demo2

Demo Gridspec02

Demo Gridspec03

Demo Gridspec04

Demo Gridspec05

Demo Gridspec06

Customizing Location of Subplot Using GridSpec

Tight Layout guide