NotImplementedError: It is not currently possible to manually set the aspect on 3D axes
Bug summary
I am making a 3d scatter plot in jupyter notebook, when I try to change the axis aspect an error raises.
Code to reproduce the error
%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
x, y, z = list(np.random.rand(3,10))
fig = plt.figure( figsize=(8,8))
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x,y,z)
ax.set_aspect("equal")
Actual outcome
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-1-2c7b67cedd81> in <module>
11 ax = fig.add_subplot(111, projection='3d')
12 ax.scatter(x,y,z)
---> 13 ax.set_aspect("equal")
/hpcfs/apps/anaconda/3.7/lib/python3.7/site-packages/matplotlib/axes/_base.py in set_aspect(self, aspect, adjustable, anchor, share)
1279 if (not cbook._str_equal(aspect, 'auto')) and self.name == '3d':
1280 raise NotImplementedError(
-> 1281 'It is not currently possible to manually set the aspect '
1282 'on 3D axes')
1283
NotImplementedError: It is not currently possible to manually set the aspect on 3D axes```
The reason for a NotImplementedError being raised is indeed that aspect is not implemented for 3D axes. This was added deliberately in #13474 to tell people about the fact that this feature does not (yet) exist.
ax.set_aspect('equal') produces wrong output for 3D axes. It was therefore removed. If you want to get wrong output, you can revert to an old version of matplotlib and continue using it.
Reacted by Bruce Cowan, Deokyun, Longyong Wu, Lars Gebraad and pangyuteng
Activity
ImportanceOfBeingErnest commented on Oct 4, 2019
The reason for a NotImplementedError being raised is indeed that aspect is not implemented for 3D axes. This was added deliberately in #13474 to tell people about the fact that this feature does not (yet) exist.
ImportanceOfBeingErnest commented on Oct 4, 2019
I guess it makes sense to close this. For further discussion I would invite people to participate in #1077 instead.
clemens-tolboom commented on Mar 5, 2020
I ran into this and had two options
ImportanceOfBeingErnest commented on Mar 5, 2020
Option 1 (using an old version) is not sensical, because it will lead to a wrong graphical representation. Again, see #1077 for details.
clemens-tolboom commented on Mar 5, 2020
Looking at #1077 does not help when receiving old code so for this issue these options seemed useful to me to report.
I checked with #1077 which was opened 12 Aug 2012 and closed 3 Mar 2019 so could not made sense from it either ... sorry :-(
ImportanceOfBeingErnest commented on Mar 5, 2020
ax.set_aspect('equal') produces wrong output for 3D axes. It was therefore removed. If you want to get wrong output, you can revert to an old version of matplotlib and continue using it.