Simple plotting to show where boxes are.
(fig, lg=None, level=0)
| 498 | |
| 499 | |
| 500 | def plot_children(fig, lg=None, level=0): |
| 501 | """Simple plotting to show where boxes are.""" |
| 502 | if lg is None: |
| 503 | _layoutgrids = fig.get_layout_engine().execute(fig) |
| 504 | lg = _layoutgrids[fig] |
| 505 | colors = mpl.rcParams["axes.prop_cycle"].by_key()["color"] |
| 506 | col = colors[level] |
| 507 | for i in range(lg.nrows): |
| 508 | for j in range(lg.ncols): |
| 509 | bb = lg.get_outer_bbox(rows=i, cols=j) |
| 510 | fig.add_artist( |
| 511 | mpatches.Rectangle(bb.p0, bb.width, bb.height, linewidth=1, |
| 512 | edgecolor='0.7', facecolor='0.7', |
| 513 | alpha=0.2, transform=fig.transFigure, |
| 514 | zorder=-3)) |
| 515 | bbi = lg.get_inner_bbox(rows=i, cols=j) |
| 516 | fig.add_artist( |
| 517 | mpatches.Rectangle(bbi.p0, bbi.width, bbi.height, linewidth=2, |
| 518 | edgecolor=col, facecolor='none', |
| 519 | transform=fig.transFigure, zorder=-2)) |
| 520 | |
| 521 | bbi = lg.get_left_margin_bbox(rows=i, cols=j) |
| 522 | fig.add_artist( |
| 523 | mpatches.Rectangle(bbi.p0, bbi.width, bbi.height, linewidth=0, |
| 524 | edgecolor='none', alpha=0.2, |
| 525 | facecolor=[0.5, 0.7, 0.5], |
| 526 | transform=fig.transFigure, zorder=-2)) |
| 527 | bbi = lg.get_right_margin_bbox(rows=i, cols=j) |
| 528 | fig.add_artist( |
| 529 | mpatches.Rectangle(bbi.p0, bbi.width, bbi.height, linewidth=0, |
| 530 | edgecolor='none', alpha=0.2, |
| 531 | facecolor=[0.7, 0.5, 0.5], |
| 532 | transform=fig.transFigure, zorder=-2)) |
| 533 | bbi = lg.get_bottom_margin_bbox(rows=i, cols=j) |
| 534 | fig.add_artist( |
| 535 | mpatches.Rectangle(bbi.p0, bbi.width, bbi.height, linewidth=0, |
| 536 | edgecolor='none', alpha=0.2, |
| 537 | facecolor=[0.5, 0.5, 0.7], |
| 538 | transform=fig.transFigure, zorder=-2)) |
| 539 | bbi = lg.get_top_margin_bbox(rows=i, cols=j) |
| 540 | fig.add_artist( |
| 541 | mpatches.Rectangle(bbi.p0, bbi.width, bbi.height, linewidth=0, |
| 542 | edgecolor='none', alpha=0.2, |
| 543 | facecolor=[0.7, 0.2, 0.7], |
| 544 | transform=fig.transFigure, zorder=-2)) |
| 545 | for ch in lg.children.flat: |
| 546 | if ch is not None: |
| 547 | plot_children(fig, ch, level=level+1) |
no test coverage detected
searching dependent graphs…