### Navigation

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

# matplotlib.pyplot.subplot2grid

`matplotlib.pyplot.``subplot2grid`(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs)

  Create a subplot in a grid. The grid is specified by shape, at location of loc, spanning rowspan, colspan cells in each direction. The index for loc is 0-based. The current figure will be used unless fig is specified.

      subplot2grid(shape, loc, rowspan=1, colspan=1)

  is identical to

      gridspec=GridSpec(shape[0], shape[1])
      subplotspec=gridspec.new_subplotspec(loc, rowspan, colspan)
      subplot(subplotspec)

## Examples using `matplotlib.pyplot.subplot2grid`

Demo Tight Layout

Demo Gridspec01

Customizing Location of Subplot Using GridSpec

Tight Layout guide