Close a figure window. Parameters ---------- fig : None or int or str or `.Figure` The figure to close. There are a number of ways to specify this: - *None*: the current figure - `.Figure`: the given `.Figure` instance - ``int``: a figure number
(fig=None)
| 619 | |
| 620 | |
| 621 | def close(fig=None): |
| 622 | """ |
| 623 | Close a figure window. |
| 624 | |
| 625 | Parameters |
| 626 | ---------- |
| 627 | fig : None or int or str or `.Figure` |
| 628 | The figure to close. There are a number of ways to specify this: |
| 629 | |
| 630 | - *None*: the current figure |
| 631 | - `.Figure`: the given `.Figure` instance |
| 632 | - ``int``: a figure number |
| 633 | - ``str``: a figure name |
| 634 | - 'all': all figures |
| 635 | |
| 636 | """ |
| 637 | if fig is None: |
| 638 | figManager = _pylab_helpers.Gcf.get_active() |
| 639 | if figManager is None: |
| 640 | return |
| 641 | else: |
| 642 | _pylab_helpers.Gcf.destroy(figManager.num) |
| 643 | elif fig == 'all': |
| 644 | _pylab_helpers.Gcf.destroy_all() |
| 645 | elif isinstance(fig, int): |
| 646 | _pylab_helpers.Gcf.destroy(fig) |
| 647 | elif hasattr(fig, 'int'): |
| 648 | # if we are dealing with a type UUID, we |
| 649 | # can use its integer representation |
| 650 | _pylab_helpers.Gcf.destroy(fig.int) |
| 651 | elif isinstance(fig, str): |
| 652 | allLabels = get_figlabels() |
| 653 | if fig in allLabels: |
| 654 | num = get_fignums()[allLabels.index(fig)] |
| 655 | _pylab_helpers.Gcf.destroy(num) |
| 656 | elif isinstance(fig, Figure): |
| 657 | _pylab_helpers.Gcf.destroy_fig(fig) |
| 658 | else: |
| 659 | raise TypeError("close() argument must be a Figure, an int, a string, " |
| 660 | "or None, not '%s'") |
| 661 | |
| 662 | |
| 663 | def clf(): |
no test coverage detected