[Matplotlib-users] Plotting in 3D. how to specify the data? From: rajtendulkar - 2011-09-27 16:55:22 Attachments: Message as HTML ```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 http://old.nabble.com/file/p32534574/temp.py 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 http://old.nabble.com/file/p32534574/temp.py temp.py -- View this message in context: http://old.nabble.com/Plotting-in-3D.-how-to-specify-the-data--tp32534574p32534574.html Sent from the matplotlib - users mailing list archive at Nabble.com. ```
 Re: [Matplotlib-users] Plotting in 3D. how to specify the data? From: Benjamin Root - 2011-09-27 17:24:29 Attachments: Message as HTML ```On Tue, Sep 27, 2011 at 11:55 AM, rajtendulkar 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 ;. 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 ; > 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 ```
 Re: [Matplotlib-users] Plotting in 3D. how to specify the data? From: rajtendulkar - 2011-09-29 07:21:38 ```Dear Ben, Thank you very much your reply. I understood that there is problem the way plot_wireframe() function requires the data. However, I am trying to understand how exactly it needs the data. For example to understand I took this random input data and did the plot - (I took random points because in some cases it was giving me straight line) X = np.array([[1,2,3], [4, 5, 6]]) Y = np.array([[37,85,19], [120,191,612]]) Z = np.array([[103,140,415], [16,217,718]]) ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10) And it gave me a wireframe 3D graph. However, I have questions regarding this plot - 1. How exactly the function plot_wireframe() interprets and plots the data? How are the co-ordinates determined? I tried to locate the points for example (1,37,103) (2,85,140) and so on... but I don't think it is like that. 2. why does it require multiple dimension If my input data is - X = np.array([1,2,3]) Y = np.array([37,85,19]) Z = np.array([103,140,415]) It gives an error ValueError: need more than 1 value to unpack Can you please tell me about these? :) Thank you very much for your reply. Regards, Raj Benjamin Root-2 wrote: > > On Tue, Sep 27, 2011 at 11:55 AM, rajtendulkar > 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 ;. 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 ; >> > > > 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 > > ------------------------------------------------------------------------------ > 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@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/Plotting-in-3D.-how-to-specify-the-data--tp32534574p32551053.html Sent from the matplotlib - users mailing list archive at Nabble.com. ```