'Poly3DCollection' object has no attribute '_facecolors2d'报错
时间: 2023-10-11 07:07:15 浏览: 670
这个报错通常是由于使用了过时的Matplotlib版本导致的。解决方法是升级Matplotlib到最新版本。可以使用以下命令来升级Matplotlib:
```
pip install --upgrade matplotlib
```
如果仍然出现相同的错误,请尝试重新安装Matplotlib:
```
pip uninstall matplotlib
pip install matplotlib
```
相关问题
'Poly3DCollection' object has no attribute '_facecolors2d'
This error message is typically encountered when using the Poly3DCollection class from the matplotlib library.
The Poly3DCollection object is used to represent a collection of 3D polygons, and is often used in conjunction with the Axes3D class.
The error message suggests that the '_facecolors2d' attribute is missing from the object. This attribute is used to store the colors of the polygon faces in 2D space.
There are several possible reasons why this error message might occur. One possible cause is that the Poly3DCollection object was not properly initialized with the necessary attributes. Another possible cause is that the object was modified in some way that caused the '_facecolors2d' attribute to be deleted or corrupted.
To fix this error, you may need to review your code and ensure that the Poly3DCollection object is properly initialized with all necessary attributes. If the object was modified in some way, you may need to revert the changes or create a new object with the correct settings.
AttributeError: 'Poly3DCollection' object has no attribute '_facecolors2d'
这个错误是因为在添加3D图的右上角注释时,使用了一个属性'_facecolors2d',但是'Poly3DCollection'对象没有这个属性。为了解决这个问题,可以使用下面的代码替换原来的代码:
p1 = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, linewidth=0, antialiased=False, label='sanwei')
p1._facecolors2d = p1._facecolor3d
p1._edgecolors2d = p1._edgecolor3d
这样就能正确显示图例了。[2]
阅读全文