Skip to content

Commit 94c5e16

Browse files
committed
pyplot: docstring improvements for draw; docstring for show
To give show a single docstring and to include it in the auto-generated docs, it is now a function defined explicitly in pyplot.py.
1 parent 261de59 commit 94c5e16

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

lib/matplotlib/pyplot.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _backend_selection():
9292
## Global ##
9393

9494
from matplotlib.backends import pylab_setup
95-
new_figure_manager, draw_if_interactive, show = pylab_setup()
95+
new_figure_manager, draw_if_interactive, _show = pylab_setup()
9696

9797
@docstring.copy_dedent(Artist.findobj)
9898
def findobj(o=None, match=None):
@@ -113,16 +113,28 @@ def switch_backend(newbackend):
113113
Calling this command will close all open windows.
114114
"""
115115
close('all')
116-
global new_figure_manager, draw_if_interactive, show
116+
global new_figure_manager, draw_if_interactive, _show
117117
matplotlib.use(newbackend, warn=False)
118118
reload(matplotlib.backends)
119119
from matplotlib.backends import pylab_setup
120-
new_figure_manager, draw_if_interactive, show = pylab_setup()
120+
new_figure_manager, draw_if_interactive, _show = pylab_setup()
121+
122+
123+
def show():
124+
"""
125+
In non-interactive mode, display all figures and block until
126+
the figures have been closed; in interactive mode it has no
127+
effect unless figures were created prior to a change from
128+
non-interactive to interactive mode (not recommended). In
129+
that case it displays the figures but does not block.
130+
"""
131+
global _show
132+
_show()
121133

122134

123135
def isinteractive():
124136
"""
125-
Return the interactive status
137+
Return *True* if matplotlib is in interactive mode, *False* otherwise.
126138
"""
127139
return matplotlib.is_interactive()
128140

@@ -354,7 +366,25 @@ def clf():
354366
draw_if_interactive()
355367

356368
def draw():
357-
'redraw the current figure'
369+
"""
370+
Redraw the current figure.
371+
372+
This is used in interactive mode to update a figure that
373+
has been altered using one or more plot object method calls;
374+
it is not needed if figure modification is done entirely
375+
with pyplot functions, if a sequence of modifications ends
376+
with a pyplot function, or if matplotlib is in non-interactive
377+
mode and the sequence of modifications ends with :func:`show` or
378+
:func:`savefig`.
379+
380+
A more object-oriented alternative, given any
381+
:class:`~matplotlib.figure.Figure` instance, :attr:`fig`, that
382+
was created using a :module:`~matplotlib.pyplot` function, is::
383+
384+
fig.canvas.draw()
385+
386+
387+
"""
358388
get_current_fig_manager().canvas.draw()
359389

360390
@docstring.copy_dedent(Figure.savefig)
@@ -1386,7 +1416,9 @@ def plotting():
13861416
setp set a graphics property
13871417
semilogx log x axis
13881418
semilogy log y axis
1389-
show show the figures
1419+
show in non-interactive mode, display all figures and block
1420+
until they have been closed; in interactive mode,
1421+
show generally has no effect.
13901422
specgram a spectrogram plot
13911423
stem make a stem plot
13921424
subplot make a subplot (numrows, numcols, axesnum)

0 commit comments

Comments
 (0)