Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/matplotlib/projections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@
from .. import axes, _docstring
from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
from .polar import PolarAxes
from mpl_toolkits.mplot3d import Axes3D

try:
from mpl_toolkits.mplot3d import Axes3D
except ImportError:
import warnings
warnings.warn("Unable to import Axes3D. This may be due to multiple versions of "
"Matplotlib being installed (e.g. as a system package and as a pip "
"package). As a result, the 3D projection is not available.")
Axes3D = None


class ProjectionRegistry:
Expand Down Expand Up @@ -87,8 +95,12 @@ def get_projection_names(self):
HammerAxes,
LambertAxes,
MollweideAxes,
Axes3D,
)
if Axes3D is not None:
projection_registry.register(Axes3D)
else:
# remove from namespace if not importable
del Axes3D


def register_projection(cls):
Expand Down