Skip to content

BUG: Problem updating scalars for points3d if scalars are provided in constructor #488

Closed

Description

@larsoner

I have a problem updating scalars in with scatter_source and glyph (e.g., if called by points3d). This works:

from mayavi import mlab
import numpy as np
x, y, z = np.random.RandomState(0).rand(3, 10)
indices = np.round(np.linspace(0, len(x)))
pts = mlab.points3d(x, y, z)
# pts = mlab.points3d(x, y, z, np.ones(len(x)))
colors = [(0, 0, 0, 255.), (255, 255, 255, 255)]
pts.glyph.scale_mode = 'data_scaling_off'
pts.glyph.color_mode = 'color_by_scalar'
pts.mlab_source.dataset.point_data.scalars = indices
pts.module_manager.scalar_lut_manager.lut.table = colors
pts.module_manager.scalar_lut_manager.data_range = [-0.5, 1.5]

screenshot from 2017-02-17 13-16-15

But changing the line to be pts = mlab.points3d(x, y, z, np.ones(len(x))) makes the later .scalars no longer do anything:

screenshot from 2017-02-17 13-18-41

I tried doing pts.mlab_source.update() but it has no effect.

Any idea why it won't update properly anymore?

Activity

  1. larsoner commented on Feb 15, 2018

    @larsoner
    CollaboratorAuthor

    I solved this by swapping p.mlab_source.scalars = indices in for the pts.mlab_source.dataset.point_data.scalars = indices line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions