此问题已在此处有答案:
gca and latest version of Matplotlib(2个答案)
9天前关闭
配置:
- Mac OS
- vs码
- Python-3.x
错误: - 验证码:*
fig = plt.figure(figsize=(10, 6))
ax = fig.gca(projection='3d')
surf1 = ax.plot_surface(X, Y, Z, rstride=2, cstride=2, cmap=mpl.cm.coolwarm, linewidth=0.5, antialiased=True) # Plots the original function surface
surf2 = ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2, label='regression') # Plots the regression surface
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('f(x, y)')
ax.legend()
fig.colorbar(surf, shrink=0.5, aspect=5)
- 错误信息:*
TypeError Traceback (most recent call last)
Cell In\[61\], line 2
1 fig = plt.figure(figsize=(10, 6))
2 ax = fig.gca(projection='3d')
3 surf1 = ax.plot_surface(X, Y, Z, rstride=2, cstride=2, cmap=mpl.cm.coolwarm, linewidth=0.5, antialiased=True) # Plots the original function surface
4 surf2 = ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2, label='regression') # Plots the regression surface
TypeError: FigureBase.gca() got an unexpected keyword argument 'projection'
<Figure size 1000x600 with 0 Axes>
我试图得到这个图像:(请参见下图)x1c 0d1x
1条答案
按热度按时间deikduxw1#
我目前使用的解决方法如下:
下面的代码是:
但我更愿意找到解决办法让gca工作。