scalar transparency mapping fails in points3d
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 316
- Avg merge
- 7h 44m
- Merged PRs (30d)
- 5
Description
I'm trying to create a mapping between scalars and the alpha channel but the alpha values always seem to be interpolated, no matter how I specify my color map:
Compare the following:
```
import numpy as np
from mayavi import mlab
np.random.seed(42)
mlab.figure(bgcolor=(1,1,1))
xyz = np.random.random((10, 3))
colors = np.repeat([1,2], xyz.shape[0]/2)
pt = mlab.points3d(xyz[:,0],xyz[:,1], xyz[:,2], colors, scale_factor=.1)
pt.glyph.color_mode='color_by_scalar'
cmap = np.array([[255, 0, 0, 255],
[0, 255, 0, 255]])
pt.module_manager.scalar_lut_manager.lut._vtk_obj.SetTableRange(1, cmap.shape[0])
pt.module_manager.scalar_lut_manager.lut.number_of_colors = cmap.shape[0]
pt.module_manager.scalar_lut_manager.lut.table = cmap
# pt.update_pipeline()
mlab.draw()
mlab.show()
```

Now make one of the colors have a different alpha value:
```
import numpy as np
from mayavi import mlab
np.random.seed(42)
mlab.figure(bgcolor=(1,1,1))
xyz = np.random.random((10, 3))
colors = np.repeat([1,2], xyz.shape[0]/2)
pt = mlab.points3d(xyz[:,0],xyz[:,1], xyz[:,2], colors, scale_factor=.1)
pt.glyph.color_mode='color_by_scalar'
cmap = np.array([[255, 0, 0, 128],
[0, 255, 0, 255]])
pt.module_manager.scalar_lut_manager.lut._vtk_obj.SetTableRange(1, cmap.shape[0])
pt.module_manager.scalar_lut_manager.lut.number_of_colors = cmap.shape[0]
pt.module_manager.scalar_lut_manager.lut.table = cmap
# pt.update_pipeline()
mlab.draw()
mlab.show()
```
And you get that every point is a little transparent now:

I've tried making the table as long as the data, but nothing changes.
```
cmap = np.array([[255, 0, 0, 128],
[0, 255, 0, 255]])
cmap = np.tile(cmap, (int(xyz.shape[0]/2), 1))
```
I've also used the `pt.update_pipeline()` as per [https://github.com/enthought/mayavi/issues/611].
Any help gratefully received!
mac os 10.13.6
```
mayavi 4.6.2 py36ha281634_4 conda-forge
python 3.6.7 h8dc6b48_1004 conda-forge
qt 4.8.7 1
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.