[Numpy-discussion] Numpy logo in VTK

klo uo klonuo@gmail....
Wed Jun 27 00:52:39 CDT 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.show()
# plt.savefig('numpy.png')
========================================

Results in attachment.


Annotation stuff can be turned off in above case like this:
========================================
ax.grid(False)

for a in (ax.w_xaxis, ax.w_yaxis, ax.w_zaxis):
    for t in a.get_ticklines()+a.get_ticklabels():
        t.set_visible(False)
    a.line.set_visible(False)
    a.pane.set_visible(False)
========================================


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 ;)

Cheers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 52277 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120627/732ad9ed/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image2.png
Type: image/png
Size: 85571 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120627/732ad9ed/attachment-0003.png 


More information about the NumPy-Discussion mailing list