A debug function to draw a rectangle around the bounding box returned by an artist's `.Artist.get_window_extent` to test whether the artist is returning the correct bbox. *props* is a dict of rectangle props with the additional property 'pad' that sets the padding around the bb
(artist, renderer, props=None, fill=True)
| 2354 | |
| 2355 | |
| 2356 | def bbox_artist(artist, renderer, props=None, fill=True): |
| 2357 | """ |
| 2358 | A debug function to draw a rectangle around the bounding |
| 2359 | box returned by an artist's `.Artist.get_window_extent` |
| 2360 | to test whether the artist is returning the correct bbox. |
| 2361 | |
| 2362 | *props* is a dict of rectangle props with the additional property |
| 2363 | 'pad' that sets the padding around the bbox in points. |
| 2364 | """ |
| 2365 | if props is None: |
| 2366 | props = {} |
| 2367 | props = props.copy() # don't want to alter the pad externally |
| 2368 | pad = props.pop('pad', 4) |
| 2369 | pad = renderer.points_to_pixels(pad) |
| 2370 | bbox = artist.get_window_extent(renderer) |
| 2371 | r = Rectangle( |
| 2372 | xy=(bbox.x0 - pad / 2, bbox.y0 - pad / 2), |
| 2373 | width=bbox.width + pad, height=bbox.height + pad, |
| 2374 | fill=fill, transform=transforms.IdentityTransform(), clip_on=False) |
| 2375 | r.update(props) |
| 2376 | r.draw(renderer) |
| 2377 | |
| 2378 | |
| 2379 | def draw_bbox(bbox, renderer, color='k', trans=None): |
nothing calls this directly
no test coverage detected
searching dependent graphs…