MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / plot_children

Function plot_children

site-packages/matplotlib/_layoutbox.py:692–735  ·  view source on GitHub ↗

Simple plotting to show where boxes are

(fig, box, level=0, printit=True)

Source from the content-addressed store, hash-verified

690
691
692def plot_children(fig, box, level=0, printit=True):
693 '''
694 Simple plotting to show where boxes are
695 '''
696 import matplotlib
697 import matplotlib.pyplot as plt
698
699 if isinstance(fig, matplotlib.figure.Figure):
700 ax = fig.add_axes([0., 0., 1., 1.])
701 ax.set_facecolor([1., 1., 1., 0.7])
702 ax.set_alpha(0.3)
703 fig.draw(fig.canvas.get_renderer())
704 else:
705 ax = fig
706
707 import matplotlib.patches as patches
708 colors = plt.rcParams["axes.prop_cycle"].by_key()["color"]
709 if printit:
710 print("Level:", level)
711 for child in box.children:
712 rect = child.get_rect()
713 if printit:
714 print(child)
715 ax.add_patch(
716 patches.Rectangle(
717 (child.left.value(), child.bottom.value()), # (x,y)
718 child.width.value(), # width
719 child.height.value(), # height
720 fc='none',
721 alpha=0.8,
722 ec=colors[level]
723 )
724 )
725 if level > 0:
726 name = child.name.split('.')[-1]
727 if level % 2 == 0:
728 ax.text(child.left.value(), child.bottom.value(), name,
729 size=12-level, color=colors[level])
730 else:
731 ax.text(child.right.value(), child.top.value(), name,
732 ha='right', va='top', size=12-level,
733 color=colors[level])
734
735 plot_children(ax, child, level=level+1, printit=printit)

Callers

nothing calls this directly

Calls 12

printFunction · 0.85
add_axesMethod · 0.80
by_keyMethod · 0.80
get_rectMethod · 0.80
add_patchMethod · 0.80
set_facecolorMethod · 0.45
set_alphaMethod · 0.45
drawMethod · 0.45
get_rendererMethod · 0.45
valueMethod · 0.45
splitMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected