[Numpy-discussion] Numpy logo in VTK

Anthony Scopatz scopatz@gmail....
Tue Jun 26 01:19:07 CDT 2012


This is awesome!

On Mon, Jun 25, 2012 at 5:27 AM, klo uo <klonuo@gmail.com> wrote:

> 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
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120626/09291144/attachment.html 


More information about the NumPy-Discussion mailing list