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.
| 173 | |
| 174 | |
| 175 | class GridSpec(GridSpecBase): |
| 176 | """ |
| 177 | A class that specifies the geometry of the grid that a subplot |
| 178 | will be placed. The location of grid is determined by similar way |
| 179 | as the SubplotParams. |
| 180 | """ |
| 181 | |
| 182 | def __init__(self, nrows, ncols, figure=None, |
| 183 | left=None, bottom=None, right=None, top=None, |
| 184 | wspace=None, hspace=None, |
| 185 | width_ratios=None, height_ratios=None): |
| 186 | """ |
| 187 | The number of rows and number of columns of the grid need to be set. |
| 188 | Optionally, the subplot layout parameters (e.g., left, right, etc.) |
| 189 | can be tuned. |
| 190 | |
| 191 | Parameters |
| 192 | ---------- |
| 193 | nrows : int |
| 194 | Number of rows in grid. |
| 195 | |
| 196 | ncols : int |
| 197 | Number or columns in grid. |
| 198 | |
| 199 | figure : ~.figure.Figure, optional |
| 200 | |
| 201 | left, right, top, bottom : float |
| 202 | Extent of the subplots as a fraction of figure width or height. |
| 203 | Left cannot be larger than right, and bottom cannot be larger than |
| 204 | top. |
| 205 | |
| 206 | wspace : float |
| 207 | The amount of width reserved for space between subplots, |
| 208 | expressed as a fraction of the average axis width. |
| 209 | |
| 210 | hspace : float |
| 211 | The amount of height reserved for space between subplots, |
| 212 | expressed as a fraction of the average axis height. |
| 213 | |
| 214 | Notes |
| 215 | ----- |
| 216 | See `~.figure.SubplotParams` for descriptions of the layout parameters. |
| 217 | """ |
| 218 | self.left = left |
| 219 | self.bottom = bottom |
| 220 | self.right = right |
| 221 | self.top = top |
| 222 | self.wspace = wspace |
| 223 | self.hspace = hspace |
| 224 | self.figure = figure |
| 225 | |
| 226 | GridSpecBase.__init__(self, nrows, ncols, |
| 227 | width_ratios=width_ratios, |
| 228 | height_ratios=height_ratios) |
| 229 | |
| 230 | if self.figure is None or not self.figure.get_constrained_layout(): |
| 231 | self._layoutbox = None |
| 232 | else: |
no outgoing calls
no test coverage detected