如何使用matplotlib绘制填充矩形棱镜

如何使用matplotlib绘制填充矩形棱镜,matplotlib,Matplotlib,我一直在尝试使用这篇文章中描述的Poly3DCollection的方法来绘制旋转矩形棱柱体的顶点。 然而,我并没有得到我期望的矩形/四边形曲面,而是得到了一个用三角形奇怪分割的曲面 如果有人能帮忙,我将不胜感激 for i in range(sample_size): # Generate randomly sized rectangle sample_shape = Rectangle(17, 7, 5) # Rotate rect

我一直在尝试使用这篇文章中描述的Poly3DCollection的方法来绘制旋转矩形棱柱体的顶点。

然而,我并没有得到我期望的矩形/四边形曲面,而是得到了一个用三角形奇怪分割的曲面

如果有人能帮忙,我将不胜感激

    for i in range(sample_size):
        # Generate randomly sized rectangle
        sample_shape = Rectangle(17, 7, 5)

        # Rotate rectangle randomly on the z-axis
        angle_of_rotation = random.randint(0, 359)
        sample_shape.rotate_rectangle(angle_of_rotation)

        fig = plt.figure()
        ax = Axes3D(fig)
        x, y, z = sample_shape.matrix[:, 0], sample_shape.matrix[:, 1], sample_shape.matrix[:, 2]
        verts = [list(zip(x, y, z))]
        ax.add_collection3d(Poly3DCollection(verts), zs=z)
        ax.set_xlim3d(-30, 30)
        ax.set_ylim3d(-30, 30)
        ax.set_zlim3d(-5, 10)

        plt.show()
我的矩形类看起来像这样

类矩形:
定义初始(self,x:float,y:float,z:float):
角点a=np.数组((-x,-y,z))
角点_b=np.数组((-x,y,z))
角点c=np.数组((x,y,z))
角点d=np.数组((x,-y,z))
角点=np.数组((-x,-y,0))
角点f=np.数组((-x,y,0))
角点数组((x,y,0))
角点h=np.数组((x,-y,0))
self.matrix=np.array((角点a、角点b、角点c、角点d、,
角(e、角(f、角(g、角(h))
你能用你的代码回答你的问题吗?你能用你的代码回答你的问题吗?