Skip to content

Commit abd560c

Browse files
committed
Add __all__ to pyplot
1 parent 28a0205 commit abd560c

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

lib/matplotlib/pyplot.py

+117
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,106 @@
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+
"color_sequences"
121+
"colorbar",
122+
"clim",
123+
"set_cmap",
124+
"imread",
125+
"imsave",
126+
"matshow",
127+
"polar",
128+
] # further expanded below with autogenerated functions
129+
38130
# fmt: off
39131

40132
from __future__ import annotations
41133

42134
from contextlib import ExitStack
43135
from enum import Enum
44136
import functools
137+
45138
import importlib
46139
import inspect
47140
import logging
@@ -4280,3 +4373,27 @@ def nipy_spectral():
42804373
image if there is one. See ``help(colormaps)`` for more information.
42814374
"""
42824375
set_cmap("nipy_spectral")
4376+
4377+
__all__ += [
4378+
"acorr", "angle_spectrum", "annotate", "arrow", "autoscale",
4379+
"axhline", "axhspan", "axis", "axline", "axvline", "axvspan", "bar",
4380+
"barbs", "barh", "bar_label", "boxplot", "broken_barh", "clabel",
4381+
"cohere", "contour", "contourf", "csd", "errorbar", "eventplot",
4382+
"fill", "fill_between", "fill_betweenx", "grid", "hexbin", "hist",
4383+
"stairs", "hist2d", "hlines", "imshow", "legend", "locator_params",
4384+
"loglog", "magnitude_spectrum", "margins", "minorticks_off",
4385+
"minorticks_on", "pcolor", "pcolormesh", "phase_spectrum", "pie",
4386+
"plot", "plot_date", "psd", "quiver", "quiverkey", "scatter",
4387+
"semilogx", "semilogy", "specgram", "spy", "stackplot", "stem",
4388+
"step", "streamplot", "table", "text", "tick_params",
4389+
"ticklabel_format", "tricontour", "tricontourf", "tripcolor",
4390+
"triplot", "violinplot", "vlines", "xcorr", "sci", "title", "xlabel",
4391+
"ylabel", "xscale", "yscale", "figimage", "figtext", "gca", "gci",
4392+
"ginput", "subplots_adjust", "suptitle", "tight_layout",
4393+
"waitforbuttonpress", "contour", "contourf", "hexbin", "scatter",
4394+
"pcolor", "pcolormesh", "hist2d", "imshow", "spy", "quiver",
4395+
"specgram", "streamplot", "tricontour", "tricontourf", "tripcolor",
4396+
"autumn", "bone", "cool", "copper", "flag", "gray", "hot", "hsv",
4397+
"jet", "pink", "prism", "spring", "summer", "winter", "magma",
4398+
"inferno", "plasma", "viridis", "nipy_spectral"
4399+
]

tools/boilerplate.py

+17
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
import functools
1919
import inspect
2020
from inspect import Parameter
21+
import itertools
2122
from pathlib import Path
2223
import sys
2324
import subprocess
25+
import textwrap
2426

2527

2628
# This line imports the installed copy of matplotlib, and not the local copy.
@@ -371,6 +373,21 @@ def boilerplate_gen():
371373
yield AUTOGEN_MSG
372374
yield CMAP_TEMPLATE.format(name=name)
373375

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

375392
def build_pyplot(pyplot_path):
376393
pyplot_orig = pyplot_path.read_text().splitlines(keepends=True)

0 commit comments

Comments
 (0)