(layoutgrids, fig)
| 266 | |
| 267 | |
| 268 | def compress_fixed_aspect(layoutgrids, fig): |
| 269 | gs = None |
| 270 | for ax in fig.axes: |
| 271 | if ax.get_subplotspec() is None: |
| 272 | continue |
| 273 | ax.apply_aspect() |
| 274 | sub = ax.get_subplotspec() |
| 275 | _gs = sub.get_gridspec() |
| 276 | if gs is None: |
| 277 | gs = _gs |
| 278 | extraw = np.zeros(gs.ncols) |
| 279 | extrah = np.zeros(gs.nrows) |
| 280 | elif _gs != gs: |
| 281 | raise ValueError('Cannot do compressed layout if Axes are not' |
| 282 | 'all from the same gridspec') |
| 283 | orig = ax.get_position(original=True) |
| 284 | actual = ax.get_position(original=False) |
| 285 | dw = orig.width - actual.width |
| 286 | if dw > 0: |
| 287 | extraw[sub.colspan] = np.maximum(extraw[sub.colspan], dw) |
| 288 | dh = orig.height - actual.height |
| 289 | if dh > 0: |
| 290 | extrah[sub.rowspan] = np.maximum(extrah[sub.rowspan], dh) |
| 291 | |
| 292 | if gs is None: |
| 293 | raise ValueError('Cannot do compressed layout if no Axes ' |
| 294 | 'are part of a gridspec.') |
| 295 | w = np.sum(extraw) / 2 |
| 296 | layoutgrids[fig].edit_margin_min('left', w) |
| 297 | layoutgrids[fig].edit_margin_min('right', w) |
| 298 | |
| 299 | h = np.sum(extrah) / 2 |
| 300 | layoutgrids[fig].edit_margin_min('top', h) |
| 301 | layoutgrids[fig].edit_margin_min('bottom', h) |
| 302 | return layoutgrids |
| 303 | |
| 304 | |
| 305 | def get_margin_from_padding(obj, *, w_pad=0, h_pad=0, |
no test coverage detected
searching dependent graphs…