On Wed, Oct 5, 2011 at 7:15 PM, Andrew C <chap8...@hotmail.com> wrote:

>  Hello List Server,
>
> I am trying to take a raster dataset, getting the center points, and the z
> value and trying to graph it in a 3D bar chart quite unsuccessfully.
>
> My data looks like this:
> XCoord = [1,2,3,4]
> YCoord = [1,2,3,4]
> ZCoord = [12,14,4,26]
>
> Those are the known locations, but there will be lots of more points when
> using actual data that forms a continuous surface over a small area.
>
> How do I create a 3D bar chart to represent the Z Value at each of those
> locations?  I saw in the help that you need to create a mesh grid, but I
> don't understand how to do that.  The help documents are vague on what the
> X,Y,Z values formats are as well.
>


The call signature of bar3d is:

bar3d(x, y, z, dx, dy, dz, color='b', kwargs**)

x, y, and z must be 1-D arrays of equivalent shapes. The values in these
arrays represent the location of a corner point of the bottom of each bar
being plotted.  This is why you see a "+ 0.25" to shift the bar over so that
the bars (should be) centered, because the bars are 0.5 wide.  The width of
the bars are given by dx, dy and the height given by dz.

For the data you have given, I would do the following:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')

XCoord = np.array([1,2,3,4])
YCoord = np.array([1,2,3,4])
ZCoord = np.array([12,14,4,26])

ax.bar3d(XCoord - 0.25, YCoord - 0.25, [0, 0, 0, 0],
         0.5, 0.5, ZCoord)

plt.show()


Cheers!
Ben Root
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to