diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 130980fa0268..f3f022a4fe26 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -23,7 +23,7 @@ import matplotlib.artist as martist from matplotlib.artist import Artist, allow_rasterization -from matplotlib.backend_bases import FigureCanvasBase +from matplotlib.backend_bases import FigureCanvasBase, NonGuiException import matplotlib.cbook as cbook import matplotlib.colorbar as cbar import matplotlib.image as mimage @@ -33,18 +33,14 @@ from matplotlib.gridspec import GridSpec import matplotlib.legend as mlegend from matplotlib.patches import Rectangle -from matplotlib.projections import (get_projection_names, - process_projection_requirements) +from matplotlib.projections import process_projection_requirements from matplotlib.text import Text, TextWithDash from matplotlib.transforms import (Affine2D, Bbox, BboxTransformTo, TransformedBbox) import matplotlib._layoutbox as layoutbox -from matplotlib.backend_bases import NonGuiException _log = logging.getLogger(__name__) -docstring.interpd.update(projection_names=get_projection_names()) - def _stale_figure_callback(self, val): if self.figure: diff --git a/lib/matplotlib/projections/__init__.py b/lib/matplotlib/projections/__init__.py index e318bbc12514..c13c16972e91 100644 --- a/lib/matplotlib/projections/__init__.py +++ b/lib/matplotlib/projections/__init__.py @@ -1,34 +1,27 @@ -from .. import axes, cbook +from .. import axes, docstring, cbook from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes from .polar import PolarAxes from mpl_toolkits.mplot3d import Axes3D class ProjectionRegistry: - """ - Manages the set of projections available to the system. - """ + """A mapping of registered projection names to projection classes.""" + def __init__(self): self._all_projection_types = {} def register(self, *projections): - """ - Register a new set of projections. - """ + """Register a new set of projections.""" for projection in projections: name = projection.name self._all_projection_types[name] = projection def get_projection_class(self, name): - """ - Get a projection class from its *name*. - """ + """Get a projection class from its *name*.""" return self._all_projection_types[name] def get_projection_names(self): - """ - Get a list of the names of all projections currently registered. - """ + """Return the names of all projections currently registered.""" return sorted(self._all_projection_types) @@ -68,8 +61,5 @@ def process_projection_requirements(figure, *args, **kwargs): return figure._process_projection_requirements(*args, **kwargs) -def get_projection_names(): - """ - Get a list of acceptable projection names. - """ - return projection_registry.get_projection_names() +get_projection_names = projection_registry.get_projection_names +docstring.interpd.update(projection_names=get_projection_names())