Skip to content

Commit 6578035

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

File tree

2 files changed

+138
-2
lines changed

2 files changed

+138
-2
lines changed

lib/matplotlib/pyplot.py

+119-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,106 @@
3535
implicit and explicit interfaces.
3636
"""
3737

38-
# fmt: off
39-
4038
from __future__ import annotations
4139

40+
__all__ = [
41+
"Annotation",
42+
"Arrow",
43+
"Artist",
44+
"AutoLocator",
45+
"Axes",
46+
"Circle",
47+
"Figure",
48+
"FixedFormatter",
49+
"FixedLocator",
50+
"FormatStrFormatter",
51+
"Formatter",
52+
"FuncFormatter",
53+
"GridSpec",
54+
"IndexLocator",
55+
"Line2D",
56+
"LinearLocator",
57+
"Locator",
58+
"LogFormatter",
59+
"LogFormatterExponent",
60+
"LogFormatterMathtext",
61+
"LogLocator",
62+
"MaxNLocator",
63+
"MultipleLocator",
64+
"Normalize",
65+
"NullFormatter",
66+
"NullLocator",
67+
"PolarAxes",
68+
"Polygon",
69+
"Rectangle",
70+
"ScalarFormatter",
71+
"Subplot",
72+
"Text",
73+
"draw_all",
74+
"findobj",
75+
"switch_backend",
76+
"show",
77+
"isinteractive",
78+
"ion",
79+
"ioff",
80+
"pause",
81+
"rc_context",
82+
"gci",
83+
"setp",
84+
"xkcd",
85+
"figure",
86+
"gcf",
87+
"fignum_exists",
88+
"get_fignums",
89+
"get_figlabels",
90+
"connect",
91+
"disconnect",
92+
"close",
93+
"clf",
94+
"draw",
95+
"savefig",
96+
"ginput",
97+
"waitforbuttonpress",
98+
"figtext",
99+
"suptitle",
100+
"figimage",
101+
"figlegend",
102+
"axes",
103+
"delaxes",
104+
"sca",
105+
"gca",
106+
"subplot",
107+
"subplot2grid",
108+
"twinx",
109+
"twiny",
110+
"subplots_adjust",
111+
"subplot_tool",
112+
"tight_layout",
113+
"box",
114+
"xlim",
115+
"ylim",
116+
"xticks",
117+
"yticks",
118+
"rgrids",
119+
"thetagrids",
120+
"get_plot_commands",
121+
"colormaps",
122+
"color_sequences",
123+
"colorbar",
124+
"clim",
125+
"set_cmap",
126+
"imread",
127+
"imsave",
128+
"matshow",
129+
"polar",
130+
] # further expanded below with autogenerated functions
131+
132+
# fmt: off
133+
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

+19
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,23 @@ 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+
all_additions = 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+
)
389+
390+
yield '\n'
391+
yield f'__all__ += [\n{all_additions}\n]\n'
392+
374393

375394
def build_pyplot(pyplot_path):
376395
pyplot_orig = pyplot_path.read_text().splitlines(keepends=True)

0 commit comments

Comments
 (0)