diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 026be7ae90cf..e436fe3d9065 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -35,13 +35,106 @@ implicit and explicit interfaces. """ -# fmt: off - from __future__ import annotations +__all__ = [ + "Annotation", + "Arrow", + "Artist", + "AutoLocator", + "Axes", + "Circle", + "Figure", + "FixedFormatter", + "FixedLocator", + "FormatStrFormatter", + "Formatter", + "FuncFormatter", + "GridSpec", + "IndexLocator", + "Line2D", + "LinearLocator", + "Locator", + "LogFormatter", + "LogFormatterExponent", + "LogFormatterMathtext", + "LogLocator", + "MaxNLocator", + "MultipleLocator", + "Normalize", + "NullFormatter", + "NullLocator", + "PolarAxes", + "Polygon", + "Rectangle", + "ScalarFormatter", + "Subplot", + "Text", + "draw_all", + "findobj", + "switch_backend", + "show", + "isinteractive", + "ion", + "ioff", + "pause", + "rc_context", + "gci", + "setp", + "xkcd", + "figure", + "gcf", + "fignum_exists", + "get_fignums", + "get_figlabels", + "connect", + "disconnect", + "close", + "clf", + "draw", + "savefig", + "ginput", + "waitforbuttonpress", + "figtext", + "suptitle", + "figimage", + "figlegend", + "axes", + "delaxes", + "sca", + "gca", + "subplot", + "subplot2grid", + "twinx", + "twiny", + "subplots_adjust", + "subplot_tool", + "tight_layout", + "box", + "xlim", + "ylim", + "xticks", + "yticks", + "rgrids", + "thetagrids", + "get_plot_commands", + "colormaps", + "color_sequences", + "colorbar", + "clim", + "set_cmap", + "imread", + "imsave", + "matshow", + "polar", +] # further expanded below with autogenerated functions + +# fmt: off + from contextlib import ExitStack from enum import Enum import functools + import importlib import inspect import logging @@ -4280,3 +4373,27 @@ def nipy_spectral(): image if there is one. See ``help(colormaps)`` for more information. """ set_cmap("nipy_spectral") + +__all__ += [ + "acorr", "angle_spectrum", "annotate", "arrow", "autoscale", + "axhline", "axhspan", "axis", "axline", "axvline", "axvspan", "bar", + "barbs", "barh", "bar_label", "boxplot", "broken_barh", "clabel", + "cohere", "contour", "contourf", "csd", "errorbar", "eventplot", + "fill", "fill_between", "fill_betweenx", "grid", "hexbin", "hist", + "stairs", "hist2d", "hlines", "imshow", "legend", "locator_params", + "loglog", "magnitude_spectrum", "margins", "minorticks_off", + "minorticks_on", "pcolor", "pcolormesh", "phase_spectrum", "pie", + "plot", "plot_date", "psd", "quiver", "quiverkey", "scatter", + "semilogx", "semilogy", "specgram", "spy", "stackplot", "stem", + "step", "streamplot", "table", "text", "tick_params", + "ticklabel_format", "tricontour", "tricontourf", "tripcolor", + "triplot", "violinplot", "vlines", "xcorr", "sci", "title", "xlabel", + "ylabel", "xscale", "yscale", "figimage", "figtext", "gca", "gci", + "ginput", "subplots_adjust", "suptitle", "tight_layout", + "waitforbuttonpress", "contour", "contourf", "hexbin", "scatter", + "pcolor", "pcolormesh", "hist2d", "imshow", "spy", "quiver", + "specgram", "streamplot", "tricontour", "tricontourf", "tripcolor", + "autumn", "bone", "cool", "copper", "flag", "gray", "hot", "hsv", + "jet", "pink", "prism", "spring", "summer", "winter", "magma", + "inferno", "plasma", "viridis", "nipy_spectral" +] diff --git a/tools/boilerplate.py b/tools/boilerplate.py index e3b4809d96b3..261de25ac55f 100644 --- a/tools/boilerplate.py +++ b/tools/boilerplate.py @@ -18,9 +18,11 @@ import functools import inspect from inspect import Parameter +import itertools from pathlib import Path import sys import subprocess +import textwrap # This line imports the installed copy of matplotlib, and not the local copy. @@ -371,6 +373,23 @@ def boilerplate_gen(): yield AUTOGEN_MSG yield CMAP_TEMPLATE.format(name=name) + # extend __all__ + all_text_wrapper = textwrap.TextWrapper( + break_long_words=False, width=74, + initial_indent=' ' * 4, subsequent_indent=' ' * 4) + + all_additions = all_text_wrapper.fill( + ', '.join([ + '"%s"' % funcname.split(':', 1)[0] + for funcname in itertools.chain( + _axes_commands, _figure_commands, cmappable, cmaps + ) + ]) + ) + + yield '\n' + yield f'__all__ += [\n{all_additions}\n]\n' + def build_pyplot(pyplot_path): pyplot_orig = pyplot_path.read_text().splitlines(keepends=True)