MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_tight_layout6

Function test_tight_layout6

lib/matplotlib/tests/test_tightlayout.py:82–120  ·  view source on GitHub ↗

Test tight_layout for gridspec.

()

Source from the content-addressed store, hash-verified

80
81@image_comparison(['tight_layout6'], style='mpl20')
82def test_tight_layout6():
83 """Test tight_layout for gridspec."""
84
85 # This raises warnings since tight layout cannot
86 # do this fully automatically. But the test is
87 # correct since the layout is manually edited
88 with warnings.catch_warnings():
89 warnings.simplefilter("ignore", UserWarning)
90 fig = plt.figure()
91
92 gs1 = mpl.gridspec.GridSpec(2, 1)
93 ax1 = fig.add_subplot(gs1[0])
94 ax2 = fig.add_subplot(gs1[1])
95
96 example_plot(ax1)
97 example_plot(ax2)
98
99 gs1.tight_layout(fig, rect=[0, 0, 0.5, 1])
100
101 gs2 = mpl.gridspec.GridSpec(3, 1)
102
103 for ss in gs2:
104 ax = fig.add_subplot(ss)
105 example_plot(ax)
106 ax.set_title("")
107 ax.set_xlabel("")
108
109 ax.set_xlabel("x-label", fontsize=12)
110
111 gs2.tight_layout(fig, rect=[0.5, 0, 1, 1], h_pad=0.45)
112
113 top = min(gs1.top, gs2.top)
114 bottom = max(gs1.bottom, gs2.bottom)
115
116 gs1.tight_layout(fig, rect=[None, 0 + (bottom-gs1.bottom),
117 0.5, 1 - (gs1.top-top)])
118 gs2.tight_layout(fig, rect=[0.5, 0 + (bottom-gs2.bottom),
119 None, 1 - (gs2.top-top)],
120 h_pad=0.45)
121
122
123@image_comparison(['tight_layout7'], style='mpl20')

Callers

nothing calls this directly

Calls 6

tight_layoutMethod · 0.95
figureMethod · 0.80
add_subplotMethod · 0.80
set_xlabelMethod · 0.80
example_plotFunction · 0.70
set_titleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…