首页 > 解决方案 > Matplotlib 图和轴背景颜色

问题描述

我想删除(红色和蓝色)或将轴和图形的颜色设置为透明(如下图)。我怎么能这样做?像 set_facecolor('transparent') 不起作用

这是我的代码:

    self.fig = Figure(figsize=(8, 7.5), dpi=55)
    self.fig.patch.set_facecolor('blue')
    self.fig.patch.set_alpha(1)

    FigureCanvas.__init__(self, self.fig)
    self.setParent(parent)
    self.ax6 = self.figure.add_subplot(111, projection='3d')
    # self.ax6.patch.set_alpha(.5)
    self.ax6.set_facecolor('red')
    m1 = mesh.Mesh.from_file('naberhaci.stl')
    m1.rotate([1, 0, 0], math.radians(00))
    self.ax6.add_collection3d(mplot3d.art3d.Poly3DCollection(m1.vectors))
    scale = m1.points.flatten()
    self.ax6.auto_scale_xyz(scale-10, scale+10, scale)

在此处输入图像描述

标签: pythonpython-3.xmatplotlibmatplotlib-widget

解决方案


推荐阅读