-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Open
Description
Bug summary
This bug arises when I plot filled contours with 3d projection and auto aspect, and save the figure as '3d-plot1.png'. Then, I set the aspect to 'equal' and back to 'auto', and save the figure as '3d-plot2.png', which is inconsistent with '3d-plot1.png'. However, this bug does not occur in 2d filled contours.
Code for reproduction
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
fig1 = plt.figure()
ax1 = fig1.add_subplot(projection=None)
X, Y, Z = axes3d.get_test_data()
ax1.contourf(X, Y, Z, cmap="coolwarm")
ax1.set_aspect('auto')
fig1.savefig('2d-plot1.png') # Correct
ax1.set_aspect('equal')
ax1.set_aspect('auto')
fig1.savefig('2d-plot2.png') # Correct (consistent with 2d-plot1.png)
fig2 = plt.figure()
ax2 = fig2.add_subplot(projection='3d')
X, Y, Z = axes3d.get_test_data()
ax2.contourf(X, Y, Z, cmap="coolwarm")
ax2.set_aspect('auto')
fig2.savefig('3d-plot1.png') # Correct
ax2.set_aspect('equal')
ax2.set_aspect('auto')
fig2.savefig('3d-plot2.png') # Wrong (inconsistent with 3d-plot1.png)Actual outcome
2d-plot1.png
2d-plot2.png
3d-plot1.png
3d-plot2.png
Expected outcome
3d-plot2.png should be the same as 3d-plot1.png.
Additional information
No response
Operating system
No response
Matplotlib Version
3.10.8
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
Reactions are currently unavailable