[Numpy-discussion] Numpy logo in VTK

klo uo klonuo at gmail.com
Wed Jun 27 01:52:39 EDT 2012

I'll try, thanks ^_^

As I said I'm learning mayavi, and wasn't expecting that drawing
trivial objects like planes would be trouble. It seems it is, and the
way to do this would be using triangular_mesh function. So I looked
elsewhere, i.e. matplotlib and abused bars:

from numpy import arange, ones
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

o = ones(4)
r = arange(4)

# planes:
for z in arange(3)+1:
    ax.bar(r, o*4, zs=z, zdir='x', alpha=.05, width=1)
    ax.bar(r, o*4, zs=z, zdir='y', alpha=.05, width=1)
    ax.bar(r, o*4, zs=z, zdir='z', alpha=.05, width=1)

# N
for i in [1, 2]:
    ax.bar3d([i], [0], [i], [.9], [.1], [.9], color='y', linewidth=.1)
    ax.bar3d(o+(i*(-1)**i), o-1, r, o-.1, o-.9, o-.1, color='y', linewidth=.1)

# cage
ax.bar3d([0], [0], [0], [4], [4], [4], alpha=.05, color='w', linewidth=0)

# plt.savefig('numpy.png')

Results in attachment.

Annotation stuff can be turned off in above case like this:

for a in (ax.w_xaxis, ax.w_yaxis, ax.w_zaxis):
    for t in a.get_ticklines()+a.get_ticklabels():

I'll try later with mayavi again, simply because it can export to 3D
format suitable for further enhancing and rendering, if needed.
Default lights in matplotlib 3D scene seem too low and colors are pale
compared to mayavi, and I'm not sure if there is way to tweak it.

Hope to see other competitors with different approach ;)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 52277 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120627/732ad9ed/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image2.png
Type: image/png
Size: 85571 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120627/732ad9ed/attachment-0001.png>

More information about the NumPy-Discussion mailing list