Create a subplot at a specific location inside a regular grid. Parameters ---------- shape : (int, int) Number of rows and of columns of the grid in which to place axis. loc : (int, int) Row number and column number of the axis location within the grid. rows
(
shape: tuple[int, int], loc: tuple[int, int],
rowspan: int = 1, colspan: int = 1,
fig: Figure | None = None,
**kwargs
)
| 2072 | |
| 2073 | |
| 2074 | def subplot2grid( |
| 2075 | shape: tuple[int, int], loc: tuple[int, int], |
| 2076 | rowspan: int = 1, colspan: int = 1, |
| 2077 | fig: Figure | None = None, |
| 2078 | **kwargs |
| 2079 | ) -> matplotlib.axes.Axes: |
| 2080 | """ |
| 2081 | Create a subplot at a specific location inside a regular grid. |
| 2082 | |
| 2083 | Parameters |
| 2084 | ---------- |
| 2085 | shape : (int, int) |
| 2086 | Number of rows and of columns of the grid in which to place axis. |
| 2087 | loc : (int, int) |
| 2088 | Row number and column number of the axis location within the grid. |
| 2089 | rowspan : int, default: 1 |
| 2090 | Number of rows for the axis to span downwards. |
| 2091 | colspan : int, default: 1 |
| 2092 | Number of columns for the axis to span to the right. |
| 2093 | fig : `.Figure`, optional |
| 2094 | Figure to place the subplot in. Defaults to the current figure. |
| 2095 | **kwargs |
| 2096 | Additional keyword arguments are handed to `~.Figure.add_subplot`. |
| 2097 | |
| 2098 | Returns |
| 2099 | ------- |
| 2100 | `~.axes.Axes` |
| 2101 | |
| 2102 | The Axes of the subplot. The returned Axes can actually be an instance |
| 2103 | of a subclass, such as `.projections.polar.PolarAxes` for polar |
| 2104 | projections. |
| 2105 | |
| 2106 | Notes |
| 2107 | ----- |
| 2108 | The following call :: |
| 2109 | |
| 2110 | ax = subplot2grid((nrows, ncols), (row, col), rowspan, colspan) |
| 2111 | |
| 2112 | is identical to :: |
| 2113 | |
| 2114 | fig = gcf() |
| 2115 | gs = fig.add_gridspec(nrows, ncols) |
| 2116 | ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan]) |
| 2117 | """ |
| 2118 | if fig is None: |
| 2119 | fig = gcf() |
| 2120 | rows, cols = shape |
| 2121 | gs = GridSpec._check_gridspec_exists(fig, rows, cols) |
| 2122 | subplotspec = gs.new_subplotspec(loc, rowspan=rowspan, colspan=colspan) |
| 2123 | return fig.add_subplot(subplotspec, **kwargs) |
| 2124 | |
| 2125 | |
| 2126 | def twinx(ax: matplotlib.axes.Axes | None = None) -> _AxesBase: |
nothing calls this directly
no test coverage detected
searching dependent graphs…