Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2947041

Browse files
committed
DOC: move figure clear what new
1 parent bfa2af3 commit 2947041

File tree

1 file changed

+33
-35
lines changed

1 file changed

+33
-35
lines changed

doc/users/whats_new.rst

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,39 @@ A legend entry can now contain more than one legend key. The extended
231231
Multiple Legend Keys
232232

233233

234+
New parameter `clear` for :func:`~matplotlib.pyplot.figure`
235+
-----------------------------------------------------------
236+
237+
When the pyplot's function :func:`~matplotlib.pyplot.figure` is called
238+
with a ``num`` parameter, a new window is only created if no existing
239+
window with the same value exists. A new bool parameter `clear` was
240+
added for explicitly clearing its existing contents. This is particularly
241+
useful when utilized in interactive sessions. Since
242+
:func:`~matplotlib.pyplot.subplots` also accepts keyword arguments
243+
from :func:`~matplotlib.pyplot.figure`, it can also be used there::
244+
245+
import matplotlib.pyplot as plt
246+
247+
fig0 = plt.figure(num=1)
248+
fig0.suptitle("A fancy plot")
249+
print("fig0.texts: ", [t.get_text() for t in fig0.texts])
250+
251+
fig1 = plt.figure(num=1, clear=False) # do not clear contents of window
252+
fig1.text(0.5, 0.5, "Really fancy!")
253+
print("fig0 is fig1: ", fig0 is fig1)
254+
print("fig1.texts: ", [t.get_text() for t in fig1.texts])
255+
256+
fig2, ax2 = plt.subplots(2, 1, num=1, clear=True) # clear contents
257+
print("fig0 is fig2: ", fig0 is fig2)
258+
print("fig2.texts: ", [t.get_text() for t in fig2.texts])
259+
260+
# The output:
261+
# fig0.texts: ['A fancy plot']
262+
# fig0 is fig1: True
263+
# fig1.texts: ['A fancy plot', 'Really fancy!']
264+
# fig0 is fig2: True
265+
# fig2.texts: []
266+
234267

235268
Internals
236269
+++++++++
@@ -267,41 +300,6 @@ Pending
267300

268301

269302

270-
271-
272-
New parameter `clear` for :func:`~matplotlib.pyplot.figure`
273-
-----------------------------------------------------------
274-
275-
When the pyplot's function :func:`~matplotlib.pyplot.figure` is called
276-
with a ``num`` parameter, a new window is only created if no existing
277-
window with the same value exists. A new bool parameter `clear` was
278-
added for explicitly clearing its existing contents. This is particularly
279-
useful when utilized in interactive sessions. Since
280-
:func:`~matplotlib.pyplot.subplots` also accepts keyword arguments
281-
from :func:`~matplotlib.pyplot.figure`, it can also be used there::
282-
283-
import matplotlib.pyplot as plt
284-
285-
fig0 = plt.figure(num=1)
286-
fig0.suptitle("A fancy plot")
287-
print("fig0.texts: ", [t.get_text() for t in fig0.texts])
288-
289-
fig1 = plt.figure(num=1, clear=False) # do not clear contents of window
290-
fig1.text(0.5, 0.5, "Really fancy!")
291-
print("fig0 is fig1: ", fig0 is fig1)
292-
print("fig1.texts: ", [t.get_text() for t in fig1.texts])
293-
294-
fig2, ax2 = plt.subplots(2, 1, num=1, clear=True) # clear contents
295-
print("fig0 is fig2: ", fig0 is fig2)
296-
print("fig2.texts: ", [t.get_text() for t in fig2.texts])
297-
298-
# The output:
299-
# fig0.texts: ['A fancy plot']
300-
# fig0 is fig1: True
301-
# fig1.texts: ['A fancy plot', 'Really fancy!']
302-
# fig0 is fig2: True
303-
# fig2.texts: []
304-
305303
AVConv writer is back
306304
---------------------
307305
Correct a bug that prevented detection of AVconv for `matplotlib.animation`.

0 commit comments

Comments
 (0)