AttributeError: 'Path3DCollection' object has no attribute '_offsets3d'
时间: 2023-08-20 14:05:44 浏览: 224
引用, label="surf") ax.legend() plt.show() A:在ax.legend()加入如下代码 surf._facecolors2d=surf._facecolors3d surf._edgecolors2d=surf._edgecolors3d 修改后代码 fig = plt.figure() ax = Axes3D(fig) X, Y = np.meshgrid(3, 3) surf = ax.plot_surface(X, Y, np.zeros([3,3], label="surf") surf._facecolors2d=surf._facecolors3d surf._edgecolors2d=surf._edgecolors3d ax.legend() plt.show()。
问题:AttributeError: 'Path3DCollection' object has no attribute '_offsets3d'
回答: 这个错误通常是由于路径集合对象没有属性'_offsets3d'导致的。具体解决方法可以尝试在绘制路径集合之前设置'_offsets3d'属性。<span class="em">1</span>
#### 引用[.reference_title]
- *1* [python使用Axes3D画三维图加入legend图例时报错AttributeError: ‘Poly3DCollection‘ object has no ...](https://blog.csdn.net/Jolen_xie/article/details/121757791)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文