Skip to content

Commit 56d9e7c

Browse files
authored
Merge pull request #19490 from Iain-S/plot-close-error-msg
Fix error message in plt.close().
2 parents 4352733 + 2879446 commit 56d9e7c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ def close(fig=None):
908908
_pylab_helpers.Gcf.destroy_fig(fig)
909909
else:
910910
raise TypeError("close() argument must be a Figure, an int, a string, "
911-
"or None, not '%s'")
911+
"or None, not %s" % type(fig))
912912

913913

914914
def clf():

lib/matplotlib/tests/test_pyplot.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,11 @@ def test_nested_ion_ioff():
153153
with plt.ioff():
154154
plt.ion()
155155
assert not mpl.is_interactive()
156+
157+
158+
def test_close():
159+
try:
160+
plt.close(1.1)
161+
except TypeError as e:
162+
assert str(e) == "close() argument must be a Figure, an int, " \
163+
"a string, or None, not <class 'float'>"

0 commit comments

Comments
 (0)