Hi,

 1/10/09 @ 18:17 (-0700), thus spake Matthew Neeley:
> Here is a snippet that might get you started:
> 
> 
> import numpy as np
> from matplotlib import pyplot as plt
> from matplotlib import cm
> import mpl_toolkits.mplot3d as plt3
> 
> data = np.random.random((8,8))**4
> cmap = cm.RdBu
> 
> fig = plt.figure()
> ax = plt3.Axes3D(fig)
> 
> d = 0.1
> 
> w, h = data.shape
> for x in range(w):
>     for y in range(h):
>         ax.bar3d([x+d], [y+d], [0], 1-d, 1-d, data[x,y], cmap(data[x,y]))
> ax.set_zlim3d((0, 1))
> plt.show()
> 
> Obviously, you should replace data with the actual data you want to
> plot (maybe numpy can help with the histogramming), and use an
> appropriate cmap for your data.  Note that in this case the entire box
> is a single color, not shaded up the side as in the example you
> referenced; I actually like it this way but I also don't know how one
> would do the shading in matplotlib.  I'll admit it's rather silly to
> have to create all these boxes individually, but that's the only way I
> could see to color each box according to its height.  The variable d
> just puts gaps between boxes; you could set this to zero to make the
> boxes adjacent.
> 
> I haven't figured out how to properly set the tick labels on the x and
> y axis in a 3d plot like this.  Also, there are often some z-order
> errors with boxes occluding each other when they shouldn't.  I don't
> know the details of how these things work internally; maybe some
> experts could weigh in here.

Great!! I like the shading this way, so no problem here.
Too bad about the rendering glitches though. Although, maybe that
can be sorted out by increasing the distance between boxes...? I will
experiment a little with this method of yours as it does basically what
I wanted. If everything fails I think I will finally use a 2-d plot
using a colour map to represent the height of bars,
as in here: http://www.davidbdean.com/wp-content/uploads/hist2d.png

Thanks a lot!

Bye.

-- 
Ernest

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to