For each Axes, make a margin between the *pos* layoutbox and the *axes* layoutbox be a minimum size that can accommodate the decorations on the axis. Then make room for colorbars. Parameters ---------- layoutgrids : dict fig : `~matplotlib.figure.Figure` `.
(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0,
hspace=0, wspace=0)
| 341 | |
| 342 | |
| 343 | def make_layout_margins(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0, |
| 344 | hspace=0, wspace=0): |
| 345 | """ |
| 346 | For each Axes, make a margin between the *pos* layoutbox and the |
| 347 | *axes* layoutbox be a minimum size that can accommodate the |
| 348 | decorations on the axis. |
| 349 | |
| 350 | Then make room for colorbars. |
| 351 | |
| 352 | Parameters |
| 353 | ---------- |
| 354 | layoutgrids : dict |
| 355 | fig : `~matplotlib.figure.Figure` |
| 356 | `.Figure` instance to do the layout in. |
| 357 | renderer : `~matplotlib.backend_bases.RendererBase` subclass. |
| 358 | The renderer to use. |
| 359 | w_pad, h_pad : float, default: 0 |
| 360 | Width and height padding (in fraction of figure). |
| 361 | hspace, wspace : float, default: 0 |
| 362 | Width and height padding as fraction of figure size divided by |
| 363 | number of columns or rows. |
| 364 | """ |
| 365 | for sfig in fig.subfigs: # recursively make child panel margins |
| 366 | ss = sfig._subplotspec |
| 367 | gs = ss.get_gridspec() |
| 368 | |
| 369 | make_layout_margins(layoutgrids, sfig, renderer, |
| 370 | w_pad=w_pad, h_pad=h_pad, |
| 371 | hspace=hspace, wspace=wspace) |
| 372 | |
| 373 | margins = get_margin_from_padding(sfig, w_pad=0, h_pad=0, |
| 374 | hspace=hspace, wspace=wspace) |
| 375 | layoutgrids[gs].edit_outer_margin_mins(margins, ss) |
| 376 | |
| 377 | for ax in fig._localaxes: |
| 378 | if not ax.get_subplotspec() or not ax.get_in_layout(): |
| 379 | continue |
| 380 | |
| 381 | ss = ax.get_subplotspec() |
| 382 | gs = ss.get_gridspec() |
| 383 | |
| 384 | if gs not in layoutgrids: |
| 385 | return |
| 386 | |
| 387 | margin = get_margin_from_padding(ax, w_pad=w_pad, h_pad=h_pad, |
| 388 | hspace=hspace, wspace=wspace) |
| 389 | pos, bbox = get_pos_and_bbox(ax, renderer) |
| 390 | # the margin is the distance between the bounding box of the Axes |
| 391 | # and its position (plus the padding from above) |
| 392 | margin['left'] += pos.x0 - bbox.x0 |
| 393 | margin['right'] += bbox.x1 - pos.x1 |
| 394 | # remember that rows are ordered from top: |
| 395 | margin['bottom'] += pos.y0 - bbox.y0 |
| 396 | margin['top'] += bbox.y1 - pos.y1 |
| 397 | |
| 398 | # make margin for colorbars. These margins go in the |
| 399 | # padding margin, versus the margin for Axes decorators. |
| 400 | for cbax in ax._colorbars: |
no test coverage detected
searching dependent graphs…