Reputation: 1
Using mayavi points3d and using cube to plot the image. Is there a way to rotate a cube to certain orientation during the plot?
mlab.figure(2)
mlab.points3d(GrainsFile[:,6],GrainsFile[:,7],GrainsFile[:,8],GrainsFile[:,11])
Upvotes: 0
Views: 553
Reputation: 2718
I had to search the Mayavi code for this one. Once I found that those cube are a GlyphSource
, I found some transformation operation in one of its methods:
import numpy
from mayavi import mlab
def test_points3d():
t = numpy.linspace(0, 4 * numpy.pi, 20)
x = numpy.sin(2 * t)
y = numpy.cos(t)
z = numpy.cos(2 * t)
s = 2 + numpy.sin(t)
points = mlab.points3d(x, y, z, s, colormap="viridis", scale_factor=.25,
mode='cube')
# rotate 45° on Z
points.glyph.glyph_source._trfm.transform.rotate_z(45)
test_points3d()
Upvotes: 2