[Matplotlib-users] ValueError: x and y must have same first dimension
Hi List I cannot figure out how to satisfy this issue to resolve the ValueError: x and y must have same first dimension. This is the relevant code: [code] for i in range( 0, time + 1 ): outflow = constant * quantity quantityChange = inflow - outflow changeList.append( quantityChange ) print %2d %9.2f %11.3f %11.3f %10.3f % ( i, inflow, quantity, outflow, quantityChange ) quantity += quantityChange # Plot on graph x = np.arange( time ) y = np.arange( quantityChange ) plt.plot( x, y, label=rate of change ) plt.ylabel( Quantity ) plt.xlabel( Time ) plt.show() [/code] I have picked up that neither a 'list' or an 'int' are iterable objects, but I am stymied by how I can successfully get the x and y axes to portray the data outputs. Also, what does that error message mean? That the starting point must be 0 or of the same object type? I haven't found a clear answer in the tutorial pages yet, but I will perservere. TIA AG -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [SOLVED] Re: ValueError: x and y must have same first dimension
Gökhan Sever wrote: On Sun, Mar 21, 2010 at 1:57 PM, AG computing.acco...@googlemail.com mailto:computing.acco...@googlemail.com wrote: Hi List I cannot figure out how to satisfy this issue to resolve the ValueError: x and y must have same first dimension. This is the relevant code: [code] for i in range( 0, time + 1 ): outflow = constant * quantity quantityChange = inflow - outflow changeList.append( quantityChange ) print %2d %9.2f %11.3f %11.3f %10.3f % ( i, inflow, quantity, outflow, quantityChange ) quantity += quantityChange # Plot on graph x = np.arange( time ) y = np.arange( quantityChange ) plt.plot( x, y, label=rate of change ) plt.ylabel( Quantity ) plt.xlabel( Time ) plt.show() [/code] I have picked up that neither a 'list' or an 'int' are iterable objects, but I am stymied by how I can successfully get the x and y axes to portray the data outputs. Also, what does that error message mean? That the starting point must be 0 or of the same object type? I haven't found a clear answer in the tutorial pages yet, but I will perservere. TIA AG x and y must be in the same length otherwise you hit that error message. try simply to see the failure: plt.plot([1,2], [1,2,3]) Use len(x) or x.shape to see how many elements in the array and adjust your code to make x and y has the same length before plotting. -- Gökhan That was very helpful, thank you Gökhan. Having played around with it a bit, I think I've got it fixed. Thanks. AG -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Using IDLE - program still running when graph window is closed
How does one ensure that once a graph has been produced by Matplotlib and that graph has been closed by the user that the program itself stops? What I am currently getting is that when I close the graph pop-up window and then close IDLE, I get a message that the program is still running and am I sure that I want to stop it. Yes, I am sure, but I don't want to have to keep killing the IDLE interpreter window in order to do so, but if I don't, then I am seemingly unable to produce another graph pop-up window. How do I control this from within the script itself? I am using Debian testing with Python 2.5.5 TIA AG -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Using IDLE - program still running when graph window is closed
C M wrote: On Wed, Feb 24, 2010 at 11:51 AM, AG computing.acco...@googlemail.com wrote: How does one ensure that once a graph has been produced by Matplotlib and that graph has been closed by the user that the program itself stops? What I am currently getting is that when I close the graph pop-up window and then close IDLE, I get a message that the program is still running and am I sure that I want to stop it. Yes, I am sure, but I don't want to have to keep killing the IDLE interpreter window in order to do so, but if I don't, then I am seemingly unable to produce another graph pop-up window. How do I control this from within the script itself? I am using Debian testing with Python 2.5.5 IDLE just doesn't work well with matplotlib (or GUI apps), as has been recently discussed here (if you Google for matplotlib and IDLE you'll find lots of posts about it). You could use ipython instead, and now there is also DreamPie (http://dreampie.sourceforge.net/), a new IDE which claims to play well with matplotlib. Those who embed their matplotlib plots in a GUI app also don't face this concern. Che Thanks Che. Have downloaded/ installed dreampie and am giving it a whirl. Haven't figured out how to load pre-written scripts and the docs are pretty near non-existent, but with enough experimentation I'm sure I'll get there. Cheers AG -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Setting graph to commence at 1 on x-axis
Hi How do I set up my matplotlib.pyplot code so that the data for the x-axis is plotted beginning at 1 not the default 0. To illustrate: I have a set of time trials and error probability calculations. Trials are x and scores are y. At present, the first trial is plotted on the graph at 0 which is illogical. I admit that I'm not sure exactly what I am looking for, but I can't see this mentioned in the docs. I just want the plot to begin at trial 1, not the 0; however, I don't mind if the x-axis has a 0 scale on it, but trials don't begin at a 0 trial, so how do I get around this. I've listed the basic code below: plt.plot( scores ) plt.ylabel( Scores ) plt.xlabel( Trials ) plt.show() TIA AG -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [SOLVED] Re: Setting graph to commence at 1 on x-axis
Angus McMorland wrote: On 24 February 2010 13:36, AG computing.acco...@googlemail.com wrote: Hi How do I set up my matplotlib.pyplot code so that the data for the x-axis is plotted beginning at 1 not the default 0. To illustrate: I have a set of time trials and error probability calculations. Trials are x and scores are y. At present, the first trial is plotted on the graph at 0 which is illogical. I admit that I'm not sure exactly what I am looking for, but I can't see this mentioned in the docs. I just want the plot to begin at trial 1, not the 0; however, I don't mind if the x-axis has a 0 scale on it, but trials don't begin at a 0 trial, so how do I get around this. I've listed the basic code below: plt.plot( scores ) plt.ylabel( Scores ) plt.xlabel( Trials ) plt.show() You can explicitly specify x-axis values: x = np.arange(len(scores)) + 1 plt.plot(x, scores) HTH, Angus. Hi Angus Thanks for the quick reply. Once I imported numpy as np and re-ran the program that did the trick perfectly. Many thanks!! All the best AG -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users