Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread Daπid
In the example you provide, bins is returned by the hist command, whereas in your code, bins is a number that you defined as 20. So, change: bins = 20 plt.hist(C, bins, ... by: nbins = 20 n, bins, patches = plt.hist(C, nbins, ... As a side comment, your data loading is too complex, and fail

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23
Hi David, I tried your fix nbins = 20 n, bins, patches = plt.hist(C, nbins, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log = False, color=None, label=None) plt.title() plt.text(25,20,'M -21.5' '\n'

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23
Just tried it with nbins set to 216 and I still get the error surfcast23 wrote: Hi David, I tried your fix nbins = 20 n, bins, patches = plt.hist(C, nbins, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid',

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread Daπid
On Fri, Jul 27, 2012 at 9:57 PM, surfcast23 surfcas...@gmail.com wrote: y = mlab.normpdf( nbins, avg, sigma) l = plt.plot(nbins, y, 'r--', linewidth=1) plt.show() You should not change bins there, as you are evaluating the gaussian function at different values. Also, sigma is a vector, but it

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23
Thanks for catching that sigma was still a vector! I am no longer getting the errors, but the best fit line is not showing up.Is there something else I am missing ? BTW thanks for the heads up on the np.mean and np.standard functions. Khary Daπid wrote: On Fri, Jul 27, 2012 at 9:57 PM,

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread Daπid
I guess it is showing, but you have many data points, so the gaussian is too small down there. You have to increase its values to make both areas fit: plt.plot(bins, N*(bins[1]-bins[0])*y, 'r--', linewidth=1) And you will get a nice gaussian fitting your data. On Fri, Jul 27, 2012 at 11:12 PM,

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23
That worked beautifully thank you! Am I reading (bins[1]-bins[0]) correctly as taking the difference between what is in the second and first bin? Daπid wrote: I guess it is showing, but you have many data points, so the gaussian is too small down there. You have to increase its values to

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread Daπid
On Sat, Jul 28, 2012 at 12:22 AM, surfcast23 surfcas...@gmail.com wrote: Am I reading (bins[1]-bins[0]) correctly as taking the difference between what is in the second and first bin? Yes. I am multipliying the width of the bins by their total height. Surely there are cleaner and more general

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-27 Thread surfcast23
Thank you for the help! Daπid wrote: On Sat, Jul 28, 2012 at 12:22 AM, surfcast23 surfcas...@gmail.com wrote: Am I reading (bins[1]-bins[0]) correctly as taking the difference between what is in the second and first bin? Yes. I am multipliying the width of the bins by their total

[Matplotlib-users] ValueError: x and y must have same first dimension

2012-07-26 Thread surfcast23
Hi I have a code to plot a histogram and I am trying to add a best fit line following this example http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo.html but run into this error Traceback (most recent call last): File /home/Astro/count_Histogram.py, line 54, in module

[Matplotlib-users] ValueError: x and y must have same first dimension

2010-03-21 Thread AG
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(

Re: [Matplotlib-users] ValueError: x and y must have same first dimension

2010-03-21 Thread Gökhan Sever
On Sun, Mar 21, 2010 at 1:57 PM, AG computing.acco...@googlemail.comwrote: 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 *