AttributeError: 'Poly3DCollection' object has no attribute '_facecolors2d'
时间: 2023-08-04 08:06:34 浏览: 189
这个错误是因为在添加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]
相关问题
AttributeError: 'Poly3DCollection' object has no attribute '_facecolors3d'
AttributeError: 'Poly3DCollection' object has no attribute '_facecolors3d' 是由于在使用Axes3D画三维图时,未正确设置Poly3DCollection对象的_facecolors3d属性,导致报错。
解决办法是在ax.legend()之前加入如下代码:
surf._facecolors2d = surf._facecolors3d
surf._edgecolors2d = surf._edgecolors3d
'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.
阅读全文