Skip to content

Commit 9847852

Browse files
committed
Allow closing a figure by long ID number.
Creating a figure with a type(long) figure number is allowed, so closing should be similarly allowed. close figure with type UUID as figure number if we can create a figure with a number that is type UUID, then it is reasonable to be able to close the figure with it as well. make the allowed int types Python 2 and 3 compatible
1 parent 2d051f2 commit 9847852

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/pyplot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,12 @@ def close(*args):
516516
arg = args[0]
517517
if arg == 'all':
518518
_pylab_helpers.Gcf.destroy_all()
519-
elif isinstance(arg, int):
519+
elif isinstance(arg, six.integer_types):
520520
_pylab_helpers.Gcf.destroy(arg)
521+
elif hasattr(arg, 'int'):
522+
# if we are dealing with a type UUID, we
523+
# can use its integer representation
524+
_pylab_helpers.Gcf.destroy(arg.int)
521525
elif is_string_like(arg):
522526
allLabels = get_figlabels()
523527
if arg in allLabels:

0 commit comments

Comments
 (0)