否,因为3D轴是matplotlib.axes._subplots.Axes3Dsubplot
对象,而规则轴是matplotlib.axes._subplots.Axessubplot
对象。
因此,不仅仅是更改现有对象的一个??属性的情况,因为它是在您创建时完全不同的对象add_subplot(projection='3d')
。
我认为您将必须显式创建子图,例如:
fig=plt.figure()
ax1=fig.add_subplot(2,2,1)
ax2=fig.add_subplot(2,2,2)
ax3=fig.add_subplot(2,2,3)
ax4=fig.add_subplot(2,2,4,projection='3d')
fig,ax = plt.subplots(nrows = 2, ncols = 2)
ax[1,1].remove()
ax[1,1]=fig.add_subplot(2,2,4,projection='3d')