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

Skip to content

Commit 8af6e67

Browse files
timhoffmtacaswell
authored andcommitted
Add __all__ to pyplot
1 parent da123bc commit 8af6e67

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

lib/matplotlib/pyplot.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,101 @@
3535
implicit and explicit interfaces.
3636
"""
3737

38+
__all__ = [
39+
'Annotation',
40+
'Arrow',
41+
'Artist',
42+
'AutoLocator',
43+
'Axes',
44+
'Circle',
45+
'Figure',
46+
'FixedFormatter',
47+
'FixedLocator',
48+
'FormatStrFormatter',
49+
'Formatter',
50+
'FuncFormatter',
51+
'GridSpec',
52+
'IndexLocator',
53+
'Line2D',
54+
'LinearLocator',
55+
'Locator',
56+
'LogFormatter',
57+
'LogFormatterExponent',
58+
'LogFormatterMathtext',
59+
'LogLocator',
60+
'MaxNLocator',
61+
'MultipleLocator',
62+
'Normalize',
63+
'NullFormatter',
64+
'NullLocator',
65+
'PolarAxes',
66+
'Polygon',
67+
'Rectangle',
68+
'ScalarFormatter',
69+
'Subplot',
70+
'Text',
71+
'draw_all',
72+
'findobj',
73+
'switch_backend',
74+
'show',
75+
'isinteractive',
76+
'ion',
77+
'ioff',
78+
'pause',
79+
'rc_context',
80+
'gci',
81+
'setp',
82+
'xkcd',
83+
'figure',
84+
'gcf',
85+
'fignum_exists',
86+
'get_fignums',
87+
'get_figlabels',
88+
'connect',
89+
'disconnect',
90+
'close',
91+
'clf',
92+
'draw',
93+
'savefig',
94+
'ginput',
95+
'waitforbuttonpress',
96+
'figtext',
97+
'suptitle',
98+
'figimage',
99+
'figlegend',
100+
'axes',
101+
'delaxes',
102+
'sca',
103+
'gca',
104+
'subplot',
105+
'subplot2grid',
106+
'twinx',
107+
'twiny',
108+
'subplots_adjust',
109+
'subplot_tool',
110+
'tight_layout',
111+
'box',
112+
'xlim',
113+
'ylim',
114+
'xticks',
115+
'yticks',
116+
'rgrids',
117+
'thetagrids',
118+
'get_plot_commands',
119+
'colormaps',
120+
'colorbar',
121+
'clim',
122+
'set_cmap',
123+
'imread',
124+
'imsave',
125+
'matshow',
126+
'polar',
127+
] # further expanded below with autogenerated functions
128+
38129
from contextlib import ExitStack
39130
from enum import Enum
40131
import functools
132+
41133
import importlib
42134
import inspect
43135
import logging
@@ -3275,3 +3367,27 @@ def nipy_spectral():
32753367
image if there is one. See ``help(colormaps)`` for more information.
32763368
"""
32773369
set_cmap('nipy_spectral')
3370+
3371+
__all__ += [
3372+
'acorr', 'angle_spectrum', 'annotate', 'arrow', 'autoscale',
3373+
'axhline', 'axhspan', 'axis', 'axline', 'axvline', 'axvspan', 'bar',
3374+
'barbs', 'barh', 'bar_label', 'boxplot', 'broken_barh', 'clabel',
3375+
'cohere', 'contour', 'contourf', 'csd', 'errorbar', 'eventplot',
3376+
'fill', 'fill_between', 'fill_betweenx', 'grid', 'hexbin', 'hist',
3377+
'stairs', 'hist2d', 'hlines', 'imshow', 'legend', 'locator_params',
3378+
'loglog', 'magnitude_spectrum', 'margins', 'minorticks_off',
3379+
'minorticks_on', 'pcolor', 'pcolormesh', 'phase_spectrum', 'pie',
3380+
'plot', 'plot_date', 'psd', 'quiver', 'quiverkey', 'scatter',
3381+
'semilogx', 'semilogy', 'specgram', 'spy', 'stackplot', 'stem',
3382+
'step', 'streamplot', 'table', 'text', 'tick_params',
3383+
'ticklabel_format', 'tricontour', 'tricontourf', 'tripcolor',
3384+
'triplot', 'violinplot', 'vlines', 'xcorr', 'sci', 'title', 'xlabel',
3385+
'ylabel', 'xscale', 'yscale', 'figimage', 'figtext', 'gca', 'gci',
3386+
'ginput', 'subplots_adjust', 'suptitle', 'tight_layout',
3387+
'waitforbuttonpress', 'contour', 'contourf', 'hexbin', 'scatter',
3388+
'pcolor', 'pcolormesh', 'hist2d', 'imshow', 'spy', 'quiver',
3389+
'specgram', 'streamplot', 'tricontour', 'tricontourf', 'tripcolor',
3390+
'autumn', 'bone', 'cool', 'copper', 'flag', 'gray', 'hot', 'hsv',
3391+
'jet', 'pink', 'prism', 'spring', 'summer', 'winter', 'magma',
3392+
'inferno', 'plasma', 'viridis', 'nipy_spectral'
3393+
]

tools/boilerplate.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from enum import Enum
1717
import inspect
1818
from inspect import Parameter
19+
import itertools
1920
from pathlib import Path
2021
import sys
2122
import textwrap
@@ -366,6 +367,21 @@ def boilerplate_gen():
366367
yield AUTOGEN_MSG
367368
yield CMAP_TEMPLATE.format(name=name)
368369

370+
# extend __all__
371+
all_text_wrapper = textwrap.TextWrapper(
372+
break_long_words=False, width=74,
373+
initial_indent=' ' * 4, subsequent_indent=' ' * 4)
374+
375+
t = all_text_wrapper.fill(
376+
', '.join([
377+
"'%s'" % funcname.split(':', 1)[0]
378+
for funcname in itertools.chain(
379+
_axes_commands, _figure_commands, cmappable, cmaps
380+
)]))
381+
382+
yield '\n'
383+
yield '__all__ += [\n{}\n]\n'.format(t)
384+
369385

370386
def build_pyplot(pyplot_path):
371387
pyplot_orig = pyplot_path.read_text().splitlines(keepends=True)

0 commit comments

Comments
 (0)