[Numpy-discussion] Numpy logo in VTK

klo uo klonuo@gmail....
Mon Jun 25 05:27:54 CDT 2012


I was reading mayavi documentation and one of the examples
(tvtk.ImageData) resembled Numpy logo grid.
I added barchart and tweaked a bit colormap and thought to post it for fun:

========================================
import numpy as np
from tvtk.api import tvtk
from mayavi import mlab

def view(dataset):
    fig = mlab.figure(bgcolor=(1, 1, 1), fgcolor=(0, 0, 0),
figure=dataset.class_name[3:])
    surf = mlab.pipeline.surface(dataset, opacity=0.2)
    mlab.pipeline.surface(mlab.pipeline.extract_edges(surf), color=(0,
0, 0), line_width=.1 )
    mlab.barchart(n, extent=[0.05, 4.5, 0.05, 4.5, -.35, 1])

n=([[1,0,0,1], [1,0,1,1], [1,1,0,1], [1,0,0,1]])

data = np.random.random((5, 5, 5))
i = tvtk.ImageData(spacing=(1, 1, 1), origin=(0, 0, 0))
i.point_data.scalars = data.ravel()
i.point_data.scalars.name = 'scalars'
i.dimensions = data.shape

view(i)
========================================


Cheers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: np.vtk.png
Type: image/png
Size: 51675 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120625/65872342/attachment-0001.png 


More information about the NumPy-Discussion mailing list