
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

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

It would be really awesome to have a script like this to generate the logo. That's pretty amazing. Would you be able to tweak it up a bit and then we could take a poll here? Perhaps we change the logo to a variation of what your script produces. Can you export a PNG? -Travis On Jun 26, 2012, at 1:52 AM, klo uo wrote:
Heh, thanks :) It's free interpretation made from quick idea then immediately shared. Original logo can be made exact I guess with interlaced planes and shallower bars or similar...
On Tue, Jun 26, 2012 at 8:19 AM, Anthony Scopatz wrote:
This is awesome!
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

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

Damn it, N is inverted and I noticed it now after posting. Sorry about that, here is correct one: ======================================== 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([3-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') ========================================

I continued in this mpl trip, with small animation sequence: ======================================== # animation ax.view_init(90,-90) plt.ion() plt.draw() plt.show() for l in arange(25): ax.set_xlim3d(1.5-.1*l,2.5+.1*l) ax.set_ylim3d(1.5-.1*l,2.5+.1*l) ax.view_init(90-3*l, -90+l) plt.draw() plt.title("NumPy") plt.ioff() plt.show() ======================================== Try it or check it out on YouTube: www.youtube.com/watch?v=mpYPS_zXAFw Whole script in attachment

You're now reminding me of the old spinning SGI logo.... http://www.youtube.com/watch?v=Nqf6TjE49N8 Brennan On 27/06/2012 10:40 a.m., klo uo wrote:
I continued in this mpl trip, with small animation sequence:
======================================== # animation ax.view_init(90,-90) plt.ion() plt.draw() plt.show()
for l in arange(25): ax.set_xlim3d(1.5-.1*l,2.5+.1*l) ax.set_ylim3d(1.5-.1*l,2.5+.1*l) ax.view_init(90-3*l, -90+l) plt.draw()
plt.title("NumPy") plt.ioff() plt.show() ========================================
Try it or check it out on YouTube: www.youtube.com/watch?v=mpYPS_zXAFw
Whole script in attachment
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Yeah, camera is in cliche, I know :D Something more original can be done, perhaps some idea of transforming grid in 2D (in Z plane) for opening sequence and then emerging latices in some analogy with numpy arrays, finishing with complete figure, but I guess not in matplotlib ;)

On 27-Jun-2012 11:40, klo uo wrote:
I continued in this mpl trip, with small animation sequence:
======================================== # animation ax.view_init(90,-90) plt.ion() plt.draw() plt.show()
for l in arange(25): ax.set_xlim3d(1.5-.1*l,2.5+.1*l) ax.set_ylim3d(1.5-.1*l,2.5+.1*l) ax.view_init(90-3*l, -90+l) plt.draw()
plt.title("NumPy") plt.ioff() plt.show() ========================================
Try it or check it out on YouTube: www.youtube.com/watch?v=mpYPS_zXAFw
Whole script in attachment
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion +1 --- looks good. --V

This is cool. It would be nice to put these things somewhere where they could be available for reference. -Travis On Jun 27, 2012, at 10:20 AM, Virgil Stokes wrote:
On 27-Jun-2012 11:40, klo uo wrote:
I continued in this mpl trip, with small animation sequence:
======================================== # animation ax.view_init(90,-90) plt.ion() plt.draw() plt.show()
for l in arange(25): ax.set_xlim3d(1.5-.1*l,2.5+.1*l) ax.set_ylim3d(1.5-.1*l,2.5+.1*l) ax.view_init(90-3*l, -90+l) plt.draw()
plt.title("NumPy") plt.ioff() plt.show() ========================================
Try it or check it out on YouTube: www.youtube.com/watch?v=mpYPS_zXAFw
Whole script in attachment
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion +1 --- looks good. --V
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

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([3-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') Umh... The first version that you posted looks ok on my screen (N is not inverted). And
On 27-Jun-2012 08:04, klo uo wrote: this version shows no difference in the "N"; but, it does show tick marks labeled with numerical values. --V

In the first version this line: ax.bar3d([i], [0], [i], [.9], [.1], [.9], color='y', linewidth=.1) is responsible for diagonal in N, and it is inverted. In the second version you quoted this is corrected with: ax.bar3d([3-i], [0], [i], [.9], [.1], [.9], color='y', linewidth=.1) Also snippet for clearing axis decorations, (grid, ticks, lines...) is posted separately besides first version. Anyhow attached python script in later mail (with youtube link) has all this together plus anim sequence On Wed, Jun 27, 2012 at 6:34 PM, Virgil Stokes <vs@it.uu.se> wrote:
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([3-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') Umh... The first version that you posted looks ok on my screen (N is not inverted). And
On 27-Jun-2012 08:04, klo uo wrote: this version shows no difference in the "N"; but, it does show tick marks labeled with numerical values.
--V _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (5)
-
Anthony Scopatz
-
Brennan Williams
-
klo uo
-
Travis Oliphant
-
Virgil Stokes