Esmail Mahjoor
Esmail Mahjoor

Reputation: 142

How to change a mayavi scene background color?

This is probably a very simple question but I couldn't find the answer anywhere! I have embedded a mayavi scene into PyQt5 and I want to change the background color. (which is available from change properties button of scene in GUI)

My code looks like this:

class Visualizer(HasTraits):
    scene = Instance(MlabSceneModel, ())
    view = View(Item('scene', height=400, show_label=False,
                     editor=SceneEditor(scene_class=MayaviScene)),
                     resizable=True)
    def __init__(self):
        super(Visualizer, self).__init__()
        self.x, self.y, self.z = ...
    @on_trait_change('scene.activated')
    def update_event(self):
        self.plot = self.scene.mlab.points3d(self.x, self.y, self.z, color=(0.5, 1, 1))

any help would be appreciated.

Upvotes: 0

Views: 769

Answers (1)

Esmail Mahjoor
Esmail Mahjoor

Reputation: 142

finally found the answer:

self.scene.background = (1, 1, 1) # for white

Upvotes: 2

Related Questions