|
From: Benjamin R. <ben...@ou...> - 2011-09-27 17:24:29
|
On Tue, Sep 27, 2011 at 11:55 AM, rajtendulkar <pra...@gm...>wrote: > Dear Forum, I am a completely new user to matplotlib. I want to plot a 3D > wireframe / surface plot with matplotlib. I am trying to understand how to > arrange the data so that I will get the correct plot. After trying a lot and > taking reference from different examples, I wrote a code given in the file > temp.py <http://old.nabble.com/file/p32534574/temp.py>. Can anyone please > tell me, how can I fix it to get a correct wireframe or surface plot? I > don't understand the array Z how it should look like. Thank You, Raj > temp.py <http://old.nabble.com/file/p32534574/temp.py> > I don't think your data is well-formed. The input X, Y, and Z needs to be 2D with the same shape. I am confused by your x and y data, which you then pass into meshgrid. To illustrate, meshgrid does this: for: x = [1, 2, 3, 4, 5] y = [1, 2, 3] then the command: X, Y = numpy.meshgrid(x, y) produces (for X): array([[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) and (for Y): array([[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3]]) Your x and y look like they are flattened versions of these. In addition, your z doesn't seem to have enough values to fit the domain. Ben Root |