On Sun, Mar 21, 2010 at 1:57 PM, AG <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
------------------------------------------------------------------------------
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

Reply via email to