`BoxStyle` is a container class which defines several boxstyle classes, which are used for `FancyBboxPatch`. A style object can be created as:: BoxStyle.Round(pad=0.2) or:: BoxStyle("Round", pad=0.2) or:: BoxStyle("Round, pad=0.2") The
| 2484 | |
| 2485 | @_docstring.interpd |
| 2486 | class BoxStyle(_Style): |
| 2487 | """ |
| 2488 | `BoxStyle` is a container class which defines several |
| 2489 | boxstyle classes, which are used for `FancyBboxPatch`. |
| 2490 | |
| 2491 | A style object can be created as:: |
| 2492 | |
| 2493 | BoxStyle.Round(pad=0.2) |
| 2494 | |
| 2495 | or:: |
| 2496 | |
| 2497 | BoxStyle("Round", pad=0.2) |
| 2498 | |
| 2499 | or:: |
| 2500 | |
| 2501 | BoxStyle("Round, pad=0.2") |
| 2502 | |
| 2503 | The following boxstyle classes are defined. |
| 2504 | |
| 2505 | %(BoxStyle:table)s |
| 2506 | |
| 2507 | An instance of a boxstyle class is a callable object, with the signature :: |
| 2508 | |
| 2509 | __call__(self, x0, y0, width, height, mutation_size) -> Path |
| 2510 | |
| 2511 | *x0*, *y0*, *width* and *height* specify the location and size of the box |
| 2512 | to be drawn; *mutation_size* scales the outline properties such as padding. |
| 2513 | """ |
| 2514 | |
| 2515 | _style_list = {} |
| 2516 | |
| 2517 | @_register_style(_style_list) |
| 2518 | class Square: |
| 2519 | """A square box.""" |
| 2520 | |
| 2521 | def __init__(self, pad=0.3): |
| 2522 | """ |
| 2523 | Parameters |
| 2524 | ---------- |
| 2525 | pad : float, default: 0.3 |
| 2526 | The amount of padding around the original box. |
| 2527 | """ |
| 2528 | self.pad = pad |
| 2529 | |
| 2530 | def __call__(self, x0, y0, width, height, mutation_size): |
| 2531 | pad = mutation_size * self.pad |
| 2532 | # width and height with padding added. |
| 2533 | width, height = width + 2 * pad, height + 2 * pad |
| 2534 | # boundary of the padded box |
| 2535 | x0, y0 = x0 - pad, y0 - pad |
| 2536 | x1, y1 = x0 + width, y0 + height |
| 2537 | return Path._create_closed( |
| 2538 | [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]) |
| 2539 | |
| 2540 | @_register_style(_style_list) |
| 2541 | class Circle: |
| 2542 | """A circular box.""" |
| 2543 |
no outgoing calls
searching dependent graphs…