警告内容:
MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6. This is consistent with other Axes classes.
ax = Axes3D(fig)
解决方法:
按照提示在Axes3D的参数中加上auto_add_to_figure=False
ax = Axes3D(fig,auto_add_to_figure=False)
后面再加上:
fig.add_axes(ax)
再运行就不会有警告了。
这篇博客介绍了如何处理在使用Matplotlib的Axes3D时遇到的弃用警告。根据提示,需要在创建Axes3D对象时设置`auto_add_to_figure=False`,然后使用`fig.add_axes(ax)`手动将其添加到图形中,以避免在未来版本中出现错误。按照这种方法修改代码后,警告信息将不再显示。

1046

被折叠的 条评论
为什么被折叠?



