Surround ax with OffsetBoxes
(ax, size=10, margin=.1, color='black')
| 189 | |
| 190 | |
| 191 | def 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 | |
| 220 | def test_tight_layout_offsetboxes(): |
no test coverage detected
searching dependent graphs…