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

Skip to content

Commit 1d66b42

Browse files
committed
FIX: use toplevel function so pickle works
1 parent 57bfa34 commit 1d66b42

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/matplotlib/pyplot.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,27 @@ def make_active(event):
530530

531531
_pylab_helpers.Gcf.set_active(figManager)
532532
figManager.canvas.figure.number = num
533+
533534
if _INSTALL_FIG_OBSERVER:
534-
def auto_draw(fig):
535-
if fig.stale and matplotlib.is_interactive():
536-
fig.canvas.draw_idle()
537-
figManager.canvas.figure.add_callback(auto_draw)
535+
figManager.canvas.figure.add_callback(_auto_draw_if_interactive)
538536

539537
return figManager.canvas.figure
540538

541539

540+
def _auto_draw_if_interactive(fig):
541+
"""
542+
This is an internal helper function for making sure that auto-redrawing
543+
works as intended in the plain python repl.
544+
545+
Parameters
546+
----------
547+
fig : Figure
548+
A figure object which is assumed to be associated with a canvas
549+
"""
550+
if fig.stale and matplotlib.is_interactive():
551+
fig.canvas.draw_idle()
552+
553+
542554
def gcf():
543555
"Get a reference to the current figure."
544556

@@ -548,6 +560,7 @@ def gcf():
548560
else:
549561
return figure()
550562

563+
551564
def fignum_exists(num):
552565
return _pylab_helpers.Gcf.has_fignum(num) or num in get_figlabels()
553566

0 commit comments

Comments
 (0)