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

Function add_offsetboxes

lib/matplotlib/tests/test_tightlayout.py:191–217  ·  view source on GitHub ↗

Surround ax with OffsetBoxes

(ax, size=10, margin=.1, color='black')

Source from the content-addressed store, hash-verified

189
190
191def add_offsetboxes(ax, size=10, margin=.1, color='black'):
192 """
193 Surround ax with OffsetBoxes
194 """
195 m, mp = margin, 1+margin
196 anchor_points = [(-m, -m), (-m, .5), (-m, mp),
197 (.5, mp), (mp, mp), (mp, .5),
198 (mp, -m), (.5, -m)]
199 for point in anchor_points:
200 da = DrawingArea(size, size)
201 background = Rectangle((0, 0), width=size,
202 height=size,
203 facecolor=color,
204 edgecolor='None',
205 linewidth=0,
206 antialiased=False)
207 da.add_artist(background)
208
209 anchored_box = AnchoredOffsetbox(
210 loc='center',
211 child=da,
212 pad=0.,
213 frameon=False,
214 bbox_to_anchor=point,
215 bbox_transform=ax.transAxes,
216 borderpad=0.)
217 ax.add_artist(anchored_box)
218
219
220def test_tight_layout_offsetboxes():

Callers 1

_subplotsFunction · 0.85

Calls 5

add_artistMethod · 0.95
DrawingAreaClass · 0.90
RectangleClass · 0.90
AnchoredOffsetboxClass · 0.90
add_artistMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…