25
25
26
26
from cycler import cycler
27
27
import matplotlib
28
- import matplotlib .colorbar
29
- from matplotlib import style
30
- from matplotlib import _pylab_helpers , interactive
31
- from matplotlib .cbook import dedent , silent_list , is_numlike
32
- from matplotlib .cbook import _string_to_bool
33
- from matplotlib .cbook import deprecated
34
- from matplotlib import docstring
28
+ from matplotlib import (
29
+ # submodules
30
+ _pylab_helpers , cm , docstring , mlab , style ,
31
+ # functions
32
+ get_backend , interactive , rc , rc_context ,
33
+ # objects
34
+ rcParams , rcParamsDefault )
35
+ from matplotlib .artist import getp , get , setp , Artist
36
+ from matplotlib .axes import Axes , Subplot
35
37
from matplotlib .backend_bases import FigureCanvasBase
38
+ from matplotlib .cbook import (
39
+ _string_to_bool , dedent , deprecated , is_numlike , silent_list )
40
+ from matplotlib .cm import get_cmap , register_cmap
36
41
from matplotlib .figure import Figure , figaspect
37
42
from matplotlib .gridspec import GridSpec
38
- from matplotlib .image import imread as _imread
39
- from matplotlib .image import imsave as _imsave
40
- from matplotlib import rcParams , rcParamsDefault , get_backend
41
- from matplotlib import rc_context
42
- from matplotlib .rcsetup import interactive_bk as _interactive_bk
43
- from matplotlib .artist import getp , get , Artist
44
- from matplotlib .artist import setp as _setp
45
- from matplotlib .axes import Axes , Subplot
43
+ from matplotlib .image import imread , imsave
46
44
from matplotlib .projections import PolarAxes
47
- from matplotlib import mlab # for csv2rec, detrend_none, window_hanning
45
+ from matplotlib . rcsetup import interactive_bk as _interactive_bk
48
46
from matplotlib .scale import get_scale_docs , get_scale_names
49
47
50
- from matplotlib import cm
51
- from matplotlib .cm import get_cmap , register_cmap
52
-
53
48
import numpy as np
54
49
55
50
# We may not need the following imports here:
@@ -252,20 +247,18 @@ def show(*args, **kw):
252
247
253
248
254
249
def isinteractive ():
255
- """
256
- Return status of interactive mode.
257
- """
250
+ """Return status of interactive mode."""
258
251
return matplotlib .is_interactive ()
259
252
260
253
261
254
def ioff ():
262
- ' Turn interactive mode off.'
255
+ """ Turn interactive mode off."""
263
256
matplotlib .interactive (False )
264
257
uninstall_repl_displayhook ()
265
258
266
259
267
260
def ion ():
268
- ' Turn interactive mode on.'
261
+ """ Turn interactive mode on."""
269
262
matplotlib .interactive (True )
270
263
install_repl_displayhook ()
271
264
@@ -303,16 +296,6 @@ def pause(interval):
303
296
time .sleep (interval )
304
297
305
298
306
- @docstring .copy_dedent (matplotlib .rc )
307
- def rc (* args , ** kwargs ):
308
- matplotlib .rc (* args , ** kwargs )
309
-
310
-
311
- @docstring .copy_dedent (matplotlib .rc_context )
312
- def rc_context (rc = None , fname = None ):
313
- return matplotlib .rc_context (rc , fname )
314
-
315
-
316
299
@docstring .copy_dedent (matplotlib .rcdefaults )
317
300
def rcdefaults ():
318
301
matplotlib .rcdefaults ()
@@ -334,10 +317,6 @@ def sci(im):
334
317
335
318
336
319
## Any Artist ##
337
- # (getp is simply imported)
338
- @docstring .copy (_setp )
339
- def setp (* args , ** kwargs ):
340
- return _setp (* args , ** kwargs )
341
320
342
321
343
322
def xkcd (scale = 1 , length = 100 , randomness = 2 ):
@@ -1314,10 +1293,9 @@ def plotting():
1314
1293
pass
1315
1294
1316
1295
1296
+ @deprecated ('2.2' )
1317
1297
def get_plot_commands ():
1318
- """
1319
- Get a sorted list of all of the plotting commands.
1320
- """
1298
+ """Get a sorted list of all of the plotting commands."""
1321
1299
# This works by searching for all functions in this module and
1322
1300
# removing a few hard-coded exclusions, as well as all of the
1323
1301
# colormap-setting functions, and anything marked as private with
@@ -1326,17 +1304,7 @@ def get_plot_commands():
1326
1304
exclude = {'colormaps' , 'colors' , 'connect' , 'disconnect' ,
1327
1305
'get_plot_commands' , 'get_current_fig_manager' , 'ginput' ,
1328
1306
'plotting' , 'waitforbuttonpress' }
1329
- exclude |= set (colormaps ())
1330
- this_module = inspect .getmodule (get_plot_commands )
1331
-
1332
- commands = set ()
1333
- for name , obj in list (six .iteritems (globals ())):
1334
- if name .startswith ('_' ) or name in exclude :
1335
- continue
1336
- if inspect .isfunction (obj ) and inspect .getmodule (obj ) is this_module :
1337
- commands .add (name )
1338
-
1339
- return sorted (commands )
1307
+ return sorted (set (__all__ ) - exclude - set (colormaps ()))
1340
1308
1341
1309
1342
1310
@deprecated ('2.1' )
@@ -1644,7 +1612,13 @@ def pad(s, l):
1644
1612
return s [:l ]
1645
1613
return s + ' ' * (l - len (s ))
1646
1614
1647
- commands = get_plot_commands ()
1615
+ # Searching for all public functions in this module (this is done when
1616
+ # defining __all__) and remove a few hard-coded exclusions, as well as all
1617
+ # of the colormap-setting functions
1618
+ exclude = {"colormaps" , "colors" , "connect" , "disconnect" ,
1619
+ "get_current_fig_manager" , "ginput" , "plotting" ,
1620
+ "waitforbuttonpress" }
1621
+ commands = sorted (set (__all__ ) - exclude - set (colormaps ()))
1648
1622
1649
1623
first_sentence = re .compile (r"(?:\s*).+?\.(?:\s+|$)" , flags = re .DOTALL )
1650
1624
@@ -1741,16 +1715,6 @@ def set_cmap(cmap):
1741
1715
im .set_cmap (cmap )
1742
1716
1743
1717
1744
- @docstring .copy_dedent (_imread )
1745
- def imread (* args , ** kwargs ):
1746
- return _imread (* args , ** kwargs )
1747
-
1748
-
1749
- @docstring .copy_dedent (_imsave )
1750
- def imsave (* args , ** kwargs ):
1751
- return _imsave (* args , ** kwargs )
1752
-
1753
-
1754
1718
def matshow (A , fignum = None , ** kw ):
1755
1719
"""
1756
1720
Display an array as a matrix in a new figure window.
@@ -2048,4 +2012,10 @@ def func():
2048
2012
_make_cmap_wrapper (_cmap )
2049
2013
2050
2014
2015
+ __all__ = sorted ([name for name , obj in globals ().items ()
2016
+ if getattr (obj , "__module__" , None ) == __name__
2017
+ and not name .startswith ("_" )]
2018
+ + ["getp" , "imread" , "imsave" , "rc" , "rc_context" , "setp" ])
2019
+
2020
+
2051
2021
_setup_pyplot_info_docstrings ()
0 commit comments