26
26
27
27
from cycler import cycler
28
28
import matplotlib
29
- import matplotlib .colorbar
30
- from matplotlib import style
31
- from matplotlib import _pylab_helpers , interactive
32
- from matplotlib .cbook import dedent , silent_list , is_numlike
33
- from matplotlib .cbook import _string_to_bool
34
- from matplotlib .cbook import deprecated
35
- from matplotlib import docstring
29
+ from matplotlib import (
30
+ # submodules
31
+ _pylab_helpers , cm , docstring , mlab , style ,
32
+ # functions
33
+ get_backend , interactive , rc , rc_context ,
34
+ # objects
35
+ rcParams , rcParamsDefault )
36
+ from matplotlib .artist import getp , get , setp , Artist
37
+ from matplotlib .axes import Axes , Subplot
36
38
from matplotlib .backend_bases import FigureCanvasBase
39
+ from matplotlib .cbook import (
40
+ _string_to_bool , dedent , deprecated , is_numlike , silent_list )
41
+ from matplotlib .cm import get_cmap , register_cmap
37
42
from matplotlib .figure import Figure , figaspect
38
43
from matplotlib .gridspec import GridSpec
39
- from matplotlib .image import imread as _imread
40
- from matplotlib .image import imsave as _imsave
41
- from matplotlib import rcParams , rcParamsDefault , get_backend
42
- from matplotlib import rc_context
43
- from matplotlib .rcsetup import interactive_bk as _interactive_bk
44
- from matplotlib .artist import getp , get , Artist
45
- from matplotlib .artist import setp as _setp
46
- from matplotlib .axes import Axes , Subplot
44
+ from matplotlib .image import imread , imsave
47
45
from matplotlib .projections import PolarAxes
48
- from matplotlib import mlab # for csv2rec, detrend_none, window_hanning
46
+ from matplotlib . rcsetup import interactive_bk as _interactive_bk
49
47
from matplotlib .scale import get_scale_docs , get_scale_names
50
48
51
- from matplotlib import cm
52
- from matplotlib .cm import get_cmap , register_cmap
53
-
54
49
import numpy as np
55
50
56
51
# 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
@@ -294,16 +287,6 @@ def pause(interval):
294
287
time .sleep (interval )
295
288
296
289
297
- @docstring .copy_dedent (matplotlib .rc )
298
- def rc (* args , ** kwargs ):
299
- matplotlib .rc (* args , ** kwargs )
300
-
301
-
302
- @docstring .copy_dedent (matplotlib .rc_context )
303
- def rc_context (rc = None , fname = None ):
304
- return matplotlib .rc_context (rc , fname )
305
-
306
-
307
290
@docstring .copy_dedent (matplotlib .rcdefaults )
308
291
def rcdefaults ():
309
292
matplotlib .rcdefaults ()
@@ -325,10 +308,6 @@ def sci(im):
325
308
326
309
327
310
## Any Artist ##
328
- # (getp is simply imported)
329
- @docstring .copy (_setp )
330
- def setp (* args , ** kwargs ):
331
- return _setp (* args , ** kwargs )
332
311
333
312
334
313
def xkcd (scale = 1 , length = 100 , randomness = 2 ):
@@ -1339,10 +1318,9 @@ def plotting():
1339
1318
pass
1340
1319
1341
1320
1321
+ @deprecated ('2.2' )
1342
1322
def get_plot_commands ():
1343
- """
1344
- Get a sorted list of all of the plotting commands.
1345
- """
1323
+ """Get a sorted list of all of the plotting commands."""
1346
1324
# This works by searching for all functions in this module and
1347
1325
# removing a few hard-coded exclusions, as well as all of the
1348
1326
# colormap-setting functions, and anything marked as private with
@@ -1351,17 +1329,7 @@ def get_plot_commands():
1351
1329
exclude = {'colormaps' , 'colors' , 'connect' , 'disconnect' ,
1352
1330
'get_plot_commands' , 'get_current_fig_manager' , 'ginput' ,
1353
1331
'plotting' , 'waitforbuttonpress' }
1354
- exclude |= set (colormaps ())
1355
- this_module = inspect .getmodule (get_plot_commands )
1356
-
1357
- commands = set ()
1358
- for name , obj in list (six .iteritems (globals ())):
1359
- if name .startswith ('_' ) or name in exclude :
1360
- continue
1361
- if inspect .isfunction (obj ) and inspect .getmodule (obj ) is this_module :
1362
- commands .add (name )
1363
-
1364
- return sorted (commands )
1332
+ return sorted (set (__all__ ) - exclude - set (colormaps ()))
1365
1333
1366
1334
1367
1335
@deprecated ('2.1' )
@@ -1669,7 +1637,13 @@ def pad(s, l):
1669
1637
return s [:l ]
1670
1638
return s + ' ' * (l - len (s ))
1671
1639
1672
- commands = get_plot_commands ()
1640
+ # Searching for all public functions in this module (this is done when
1641
+ # defining __all__) and remove a few hard-coded exclusions, as well as all
1642
+ # of the colormap-setting functions
1643
+ exclude = {"colormaps" , "colors" , "connect" , "disconnect" ,
1644
+ "get_current_fig_manager" , "ginput" , "plotting" ,
1645
+ "waitforbuttonpress" }
1646
+ commands = sorted (set (__all__ ) - exclude - set (colormaps ()))
1673
1647
1674
1648
first_sentence = re .compile (r"(?:\s*).+?\.(?:\s+|$)" , flags = re .DOTALL )
1675
1649
@@ -1766,16 +1740,6 @@ def set_cmap(cmap):
1766
1740
im .set_cmap (cmap )
1767
1741
1768
1742
1769
- @docstring .copy_dedent (_imread )
1770
- def imread (* args , ** kwargs ):
1771
- return _imread (* args , ** kwargs )
1772
-
1773
-
1774
- @docstring .copy_dedent (_imsave )
1775
- def imsave (* args , ** kwargs ):
1776
- return _imsave (* args , ** kwargs )
1777
-
1778
-
1779
1743
def matshow (A , fignum = None , ** kw ):
1780
1744
"""
1781
1745
Display an array as a matrix in a new figure window.
@@ -2073,4 +2037,10 @@ def func():
2073
2037
_make_cmap_wrapper (_cmap )
2074
2038
2075
2039
2040
+ __all__ = sorted ([name for name , obj in globals ().items ()
2041
+ if getattr (obj , "__module__" , None ) == __name__
2042
+ and not name .startswith ("_" )]
2043
+ + ["getp" , "imread" , "imsave" , "rc" , "rc_context" , "setp" ])
2044
+
2045
+
2076
2046
_setup_pyplot_info_docstrings ()
0 commit comments