Bug summary
In "API Changes - Behavior changes" (https://matplotlib.org/api/api_changes.html#behavior-changes) it says
"mplot3d auto-registration
mpl_toolkits.mplot3d is always registered by default now. It is no longer necessary to import mplot3d to create 3d axes with
ax = fig.add_subplot(111, projection="3d")"
I am not seeing this behaviour.
Code for reproduction
import matplotlib.pyplot as plt fig3 = plt.figure() ax3 = fig3.add_subplot(111, projection='3d')
and
mpl.projections.get_projection_names()
Actual outcome
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~/Berechnung/lib64/python3.6/site-packages/matplotlib/projections/__init__.py in get_projection_class(projection) 57 try: ---> 58 return projection_registry.get_projection_class(projection) 59 except KeyError: ~/Berechnung/lib64/python3.6/site-packages/matplotlib/projections/__init__.py in get_projection_class(self, name) 24 """ ---> 25 return self._all_projection_types[name] 26 KeyError: '3d' During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) <ipython-input-2-95b16d9d7a18> in <module> 1 import matplotlib.pyplot as plt 2 fig3 = plt.figure() ----> 3 ax3 = fig3.add_subplot(111, projection='3d') ~/Berechnung/lib64/python3.6/site-packages/matplotlib/figure.py in add_subplot(self, *args, **kwargs) 1394 else: 1395 projection_class, kwargs, key = \ -> 1396 self._process_projection_requirements(*args, **kwargs) 1397 1398 # try to find the axes with this key in the stack ~/Berechnung/lib64/python3.6/site-packages/matplotlib/figure.py in _process_projection_requirements(self, polar, projection, *args, **kwargs) 1118 1119 if isinstance(projection, str) or projection is None: -> 1120 projection_class = projections.get_projection_class(projection) 1121 elif hasattr(projection, '_as_mpl_axes'): 1122 projection_class, extra_kwargs = projection._as_mpl_axes() ~/Berechnung/lib64/python3.6/site-packages/matplotlib/projections/__init__.py in get_projection_class(projection) 58 return projection_registry.get_projection_class(projection) 59 except KeyError: ---> 60 raise ValueError("Unknown projection %r" % projection) 61 62 ValueError: Unknown projection '3d' <Figure size 432x288 with 0 Axes>
['aitoff', 'hammer', 'lambert', 'mollweide', 'polar', 'rectilinear']
Expected outcome
An Axes3d object and the following output of mpl.projections.get_projection_names():
['3d', 'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', 'rectilinear']
Matplotlib version
Matplotlib is running in a python environment and was installed with pip.
This is only in 3.2 (not released yet), looks like the 3.1 whatsnew accidentally included some 3.2 stuff.
Thanks for this information! Then the 3.1 whatsnew should be updated, no?
Activity
anntzer commented on Jan 12, 2020
This is only in 3.2 (not released yet), looks like the 3.1 whatsnew accidentally included some 3.2 stuff.
pajot commented on Jan 12, 2020
Thanks for this information! Then the 3.1 whatsnew should be updated, no?