I am learning tensorflow recently, and there is an exercise in using matplotlib to draw a 3D image. I encountered the following problems when running the code
![](https://img-blog.csdnimg.cn/img_convert/e96efbaa4432b8ca63cecfaed194b67a.png)
TypeError: FigureBase.gca() got an unexpected keyword argument 'projection
I found that the Axes3D function was not used (line 5 in the picture). After querying and experimenting with some solutions on the Internet, I will record it now.
Solution:
ax = fig.gca(projection='3d') #原来的代码
ax = fig.add_axes(Axes3D(fig)) #改正后的代码
The actual effect is shown in the figure:
![](https://img-blog.csdnimg.cn/img_convert/7fa43e6e6bb982295c31495a19f0bff8.png)