27
27
28
28
from cycler import cycler
29
29
import matplotlib
30
- import matplotlib .colorbar
31
- from matplotlib import style
32
- from matplotlib import _pylab_helpers , interactive
33
- from matplotlib .cbook import dedent , silent_list , is_numlike
34
- from matplotlib .cbook import _string_to_bool
35
- from matplotlib .cbook import deprecated , warn_deprecated
36
- from matplotlib import docstring
30
+ from matplotlib import (
31
+ # submodules
32
+ _pylab_helpers , cbook , cm , docstring , mlab , style ,
33
+ # functions
34
+ get_backend , interactive , rc , rc_context ,
35
+ # objects
36
+ rcParams , rcParamsDefault )
37
+ from matplotlib .artist import getp , get , setp , Artist
38
+ from matplotlib .axes import Axes , Subplot
37
39
from matplotlib .backend_bases import FigureCanvasBase
40
+ from matplotlib .cbook import (
41
+ _string_to_bool , dedent , deprecated , is_numlike , silent_list )
42
+ from matplotlib .cm import get_cmap , register_cmap
38
43
from matplotlib .figure import Figure , figaspect
39
44
from matplotlib .gridspec import GridSpec
40
- from matplotlib .image import imread as _imread
41
- from matplotlib .image import imsave as _imsave
42
- from matplotlib import rcParams , rcParamsDefault , get_backend
43
- from matplotlib import rc_context
44
- from matplotlib .rcsetup import interactive_bk as _interactive_bk
45
- from matplotlib .artist import getp , get , Artist
46
- from matplotlib .artist import setp as _setp
47
- from matplotlib .axes import Axes , Subplot
45
+ from matplotlib .image import imread , imsave
48
46
from matplotlib .projections import PolarAxes
49
- from matplotlib import mlab # for csv2rec, detrend_none, window_hanning
47
+ from matplotlib . rcsetup import interactive_bk as _interactive_bk
50
48
from matplotlib .scale import get_scale_docs , get_scale_names
51
49
52
- from matplotlib import cm
53
- from matplotlib .cm import get_cmap , register_cmap
54
-
55
50
import numpy as np
56
51
57
52
# We may not need the following imports here:
@@ -253,9 +248,7 @@ def show(*args, **kw):
253
248
254
249
255
250
def isinteractive ():
256
- """
257
- Return status of interactive mode.
258
- """
251
+ """Return status of interactive mode."""
259
252
return matplotlib .is_interactive ()
260
253
261
254
@@ -297,16 +290,6 @@ def pause(interval):
297
290
time .sleep (interval )
298
291
299
292
300
- @docstring .copy_dedent (matplotlib .rc )
301
- def rc (* args , ** kwargs ):
302
- matplotlib .rc (* args , ** kwargs )
303
-
304
-
305
- @docstring .copy_dedent (matplotlib .rc_context )
306
- def rc_context (rc = None , fname = None ):
307
- return matplotlib .rc_context (rc , fname )
308
-
309
-
310
293
@docstring .copy_dedent (matplotlib .rcdefaults )
311
294
def rcdefaults ():
312
295
matplotlib .rcdefaults ()
@@ -328,10 +311,6 @@ def sci(im):
328
311
329
312
330
313
## Any Artist ##
331
- # (getp is simply imported)
332
- @docstring .copy (_setp )
333
- def setp (* args , ** kwargs ):
334
- return _setp (* args , ** kwargs )
335
314
336
315
337
316
def xkcd (scale = 1 , length = 100 , randomness = 2 ):
@@ -719,10 +698,9 @@ def axes(arg=None, **kwargs):
719
698
return subplot (111 , ** kwargs )
720
699
721
700
if isinstance (arg , Axes ):
722
- warn_deprecated ("2.2" ,
723
- message = "Using pyplot.axes(ax) with ax an Axes "
724
- "argument is deprecated. Please use "
725
- "pyplot.sca(ax) instead." )
701
+ cbook .warn_deprecated (
702
+ "2.2" , "Using pyplot.axes(ax) with ax an Axes argument is "
703
+ "deprecated. Please use pyplot.sca(ax) instead." )
726
704
ax = arg
727
705
sca (ax )
728
706
return ax
@@ -1351,10 +1329,9 @@ def plotting():
1351
1329
pass
1352
1330
1353
1331
1332
+ @deprecated ('2.2' )
1354
1333
def get_plot_commands ():
1355
- """
1356
- Get a sorted list of all of the plotting commands.
1357
- """
1334
+ """Get a sorted list of all of the plotting commands."""
1358
1335
# This works by searching for all functions in this module and
1359
1336
# removing a few hard-coded exclusions, as well as all of the
1360
1337
# colormap-setting functions, and anything marked as private with
@@ -1363,17 +1340,7 @@ def get_plot_commands():
1363
1340
exclude = {'colormaps' , 'colors' , 'connect' , 'disconnect' ,
1364
1341
'get_plot_commands' , 'get_current_fig_manager' , 'ginput' ,
1365
1342
'plotting' , 'waitforbuttonpress' }
1366
- exclude |= set (colormaps ())
1367
- this_module = inspect .getmodule (get_plot_commands )
1368
-
1369
- commands = set ()
1370
- for name , obj in list (six .iteritems (globals ())):
1371
- if name .startswith ('_' ) or name in exclude :
1372
- continue
1373
- if inspect .isfunction (obj ) and inspect .getmodule (obj ) is this_module :
1374
- commands .add (name )
1375
-
1376
- return sorted (commands )
1343
+ return sorted (set (__all__ ) - exclude - set (colormaps ()))
1377
1344
1378
1345
1379
1346
@deprecated ('2.1' )
@@ -1681,7 +1648,13 @@ def pad(s, l):
1681
1648
return s [:l ]
1682
1649
return s + ' ' * (l - len (s ))
1683
1650
1684
- commands = get_plot_commands ()
1651
+ # Searching for all public functions in this module (this is done when
1652
+ # defining __all__) and remove a few hard-coded exclusions, as well as all
1653
+ # of the colormap-setting functions
1654
+ exclude = {"colormaps" , "colors" , "connect" , "disconnect" ,
1655
+ "get_current_fig_manager" , "ginput" , "plotting" ,
1656
+ "waitforbuttonpress" }
1657
+ commands = sorted (set (__all__ ) - exclude - set (colormaps ()))
1685
1658
1686
1659
first_sentence = re .compile (r"(?:\s*).+?\.(?:\s+|$)" , flags = re .DOTALL )
1687
1660
@@ -1778,16 +1751,6 @@ def set_cmap(cmap):
1778
1751
im .set_cmap (cmap )
1779
1752
1780
1753
1781
- @docstring .copy_dedent (_imread )
1782
- def imread (* args , ** kwargs ):
1783
- return _imread (* args , ** kwargs )
1784
-
1785
-
1786
- @docstring .copy_dedent (_imsave )
1787
- def imsave (* args , ** kwargs ):
1788
- return _imsave (* args , ** kwargs )
1789
-
1790
-
1791
1754
def matshow (A , fignum = None , ** kw ):
1792
1755
"""
1793
1756
Display an array as a matrix in a new figure window.
@@ -2085,4 +2048,10 @@ def func():
2085
2048
_make_cmap_wrapper (_cmap )
2086
2049
2087
2050
2051
+ __all__ = sorted ([name for name , obj in globals ().items ()
2052
+ if getattr (obj , "__module__" , None ) == __name__
2053
+ and not name .startswith ("_" )]
2054
+ + ["getp" , "imread" , "imsave" , "rc" , "rc_context" , "setp" ])
2055
+
2056
+
2088
2057
_setup_pyplot_info_docstrings ()
0 commit comments