ValueError: x and y must have same first dimension

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>
    l = plt.plot(bins, y, 'r--', linewidth=1)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2467, in
plot
    ret = ax.plot(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 3893, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 322, in
_grab_next_args
    for seg in self._plot_args(remaining, kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 300, in
_plot_args
    x, y = self._xy_from_xy(x, y)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 240, in
_xy_from_xy
    raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension

My Code

import matplotlib.pyplot as plt
import math
import numpy as np
import mpl_toolkits.mplot3d.axes3d
import matplotlib.mlab as mlab

counts = []
F = '/home/Astro/outfiles/outmag21_5dr_38_68.txt'
f = open(F)
for line in f:
if line != ' ':
    columns = line.split()
    count = columns[3]
    count = int(count)
    counts.append(count)
    C = np.array(counts, dtype=float)
    
avg = sum(C)/len(C)
diff = C-avg
sigma = np.sqrt((1./len(C))*(diff**2))

bins = 20
plt.hist(C, bins, 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' 'N Halos 3877' '\n' 'Length Cell 38.68Mpc'
'\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
plt.xlabel("Halos/Cell")
plt.ylabel("Number Cells with N Halos")
y = mlab.normpdf( bins, avg, sigma)
print(len(y))
l = plt.plot(bins, y, 'r--', linewidth=1)
plt.show()

My first question is do x and y refer to the values in l = plt.plot(bins,
y, 'r--', linewidth=1) which for my case are bins and y?
if that is the case how can I get then to be the same first dimension?

···

--
View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34218704.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

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 prone. I
suggest you to have a look at the numpy function for that, loadfromtxt
or (I like it more), genfromtxt. It would be something like:

data=np.genfromtxt(F, delimiter=' ')
C=data[:,3]

Much easier, and way faster.

Regards,

David.

···

On Fri, Jul 27, 2012 at 4:13 AM, surfcast23 <surfcast23@...287...> wrote:

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>
    l = plt.plot(bins, y, 'r--', linewidth=1)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2467, in
plot
    ret = ax.plot(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 3893, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 322, in
_grab_next_args
    for seg in self._plot_args(remaining, kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 300, in
_plot_args
    x, y = self._xy_from_xy(x, y)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 240, in
_xy_from_xy
    raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension

My Code

import matplotlib.pyplot as plt
import math
import numpy as np
import mpl_toolkits.mplot3d.axes3d
import matplotlib.mlab as mlab

counts = []
F = '/home/Astro/outfiles/outmag21_5dr_38_68.txt'
f = open(F)
for line in f:
if line != ' ':
    columns = line.split()
    count = columns[3]
    count = int(count)
    counts.append(count)
    C = np.array(counts, dtype=float)

avg = sum(C)/len(C)
diff = C-avg
sigma = np.sqrt((1./len(C))*(diff**2))

bins = 20
plt.hist(C, bins, 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' 'N Halos 3877' '\n' 'Length Cell 38.68Mpc'
'\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
plt.xlabel("Halos/Cell")
plt.ylabel("Number Cells with N Halos")
y = mlab.normpdf( bins, avg, sigma)
print(len(y))
l = plt.plot(bins, y, 'r--', linewidth=1)
plt.show()

My first question is do x and y refer to the values in l = plt.plot(bins,
y, 'r--', linewidth=1) which for my case are bins and y?
if that is the case how can I get then to be the same first dimension?
--
View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34218704.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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' 'N Halos 3877' '\n' 'Length Cell 38.68Mpc'
'\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
plt.xlabel("Halos/Cell")
plt.ylabel("Number Cells with N Halos")
y = mlab.normpdf( nbins, avg, sigma)
l = plt.plot(nbins, y, 'r--', linewidth=1)
plt.show()

But I am still getting the error. I printed y.shape which gave (216,) so
does that mean that bins also needs to have 216 as a first dimension? Thank
you

Khary

Daπid wrote:

···

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 prone. I
suggest you to have a look at the numpy function for that, loadfromtxt
or (I like it more), genfromtxt. It would be something like:

data=np.genfromtxt(F, delimiter=' ')
C=data[:,3]

Much easier, and way faster.

Regards,

David.

On Fri, Jul 27, 2012 at 4:13 AM, surfcast23 <surfcast23@...287...> wrote:

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>
    l = plt.plot(bins, y, 'r--', linewidth=1)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2467, in
plot
    ret = ax.plot(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 3893, in
plot
    for line in self._get_lines(*args, **kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 322, in
_grab_next_args
    for seg in self._plot_args(remaining, kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 300, in
_plot_args
    x, y = self._xy_from_xy(x, y)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 240, in
_xy_from_xy
    raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension

My Code

import matplotlib.pyplot as plt
import math
import numpy as np
import mpl_toolkits.mplot3d.axes3d
import matplotlib.mlab as mlab

counts = []
F = '/home/Astro/outfiles/outmag21_5dr_38_68.txt'
f = open(F)
for line in f:
if line != ' ':
    columns = line.split()
    count = columns[3]
    count = int(count)
    counts.append(count)
    C = np.array(counts, dtype=float)

avg = sum(C)/len(C)
diff = C-avg
sigma = np.sqrt((1./len(C))*(diff**2))

bins = 20
plt.hist(C, bins, 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' 'N Halos 3877' '\n' 'Length Cell
38.68Mpc'
'\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
plt.xlabel("Halos/Cell")
plt.ylabel("Number Cells with N Halos")
y = mlab.normpdf( bins, avg, sigma)
print(len(y))
l = plt.plot(bins, y, 'r--', linewidth=1)
plt.show()

My first question is do x and y refer to the values in l =
plt.plot(bins,
y, 'r--', linewidth=1) which for my case are bins and y?
if that is the case how can I get then to be the same first dimension?
--
View this message in context:
http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34218704.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222551.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

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',
orientation='vertical', rwidth=None, log = False, color=None, label=None)
plt.title("")
plt.text(25,20,'M < -21.5' '\n' 'N Halos 3877' '\n' 'Length Cell 38.68Mpc'
'\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
plt.xlabel("Halos/Cell")
plt.ylabel("Number Cells with N Halos")
y = mlab.normpdf( nbins, avg, sigma)
l = plt.plot(nbins, y, 'r--', linewidth=1)
plt.show()

But I am still getting the error. I printed y.shape which gave (216,) so
does that mean that bins also needs to have 216 as a first dimension?
Thank you

Khary

Daπid wrote:

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 prone. I
suggest you to have a look at the numpy function for that, loadfromtxt
or (I like it more), genfromtxt. It would be something like:

data=np.genfromtxt(F, delimiter=' ')
C=data[:,3]

Much easier, and way faster.

Regards,

David.

On Fri, Jul 27, 2012 at 4:13 AM, surfcast23 <surfcast23@...287...> wrote:

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>
    l = plt.plot(bins, y, 'r--', linewidth=1)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2467,
in
plot
    ret = ax.plot(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 3893, in
plot
    for line in self._get_lines(*args, **kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 322, in
_grab_next_args
    for seg in self._plot_args(remaining, kwargs):
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 300, in
_plot_args
    x, y = self._xy_from_xy(x, y)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 240, in
_xy_from_xy
    raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension

My Code

import matplotlib.pyplot as plt
import math
import numpy as np
import mpl_toolkits.mplot3d.axes3d
import matplotlib.mlab as mlab

counts = []
F = '/home/Astro/outfiles/outmag21_5dr_38_68.txt'
f = open(F)
for line in f:
if line != ' ':
    columns = line.split()
    count = columns[3]
    count = int(count)
    counts.append(count)
    C = np.array(counts, dtype=float)

avg = sum(C)/len(C)
diff = C-avg
sigma = np.sqrt((1./len(C))*(diff**2))

bins = 20
plt.hist(C, bins, 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' 'N Halos 3877' '\n' 'Length Cell
38.68Mpc'
'\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ')
plt.xlabel("Halos/Cell")
plt.ylabel("Number Cells with N Halos")
y = mlab.normpdf( bins, avg, sigma)
print(len(y))
l = plt.plot(bins, y, 'r--', linewidth=1)
plt.show()

My first question is do x and y refer to the values in l =
plt.plot(bins,
y, 'r--', linewidth=1) which for my case are bins and y?
if that is the case how can I get then to be the same first dimension?
--
View this message in context:
http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34218704.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222567.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

You should not change bins there, as you are evaluating the gaussian
function at different values.

Also, sigma is a vector, but it should be an scalar:

sigma = np.sqrt((1./len(C))*(diff**2))

should be

sigma = np.sum(np.sqrt((1./len(C))*(diff**2))) # The sum of the previous

But, much better, you can change the three lines of code by:

avg=np.mean(C)
sigma=np.std(C)

They are way faster and more numerically accurate and stable.

As a rule of thumb, if you want to do something simple, think that
there should be an easy way of doing it. And if it is something people
do every day (like taking the mean or the std of a vector, or loading
from a txt file), there should be a very easy way of doing it. :slight_smile: And
it would probably be faster and more flexible than any naive
implementation.

Good luck with your galaxies!

···

On Fri, Jul 27, 2012 at 9:57 PM, surfcast23 <surfcast23@...287...> wrote:

y = mlab.normpdf( nbins, avg, sigma)
l = plt.plot(nbins, y, 'r--', linewidth=1)
plt.show()

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, surfcast23 <surfcast23@...287...> 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 should be an scalar:

sigma = np.sqrt((1./len(C))*(diff**2))

should be

sigma = np.sum(np.sqrt((1./len(C))*(diff**2))) # The sum of the
previous

But, much better, you can change the three lines of code by:

avg=np.mean(C)
sigma=np.std(C)

They are way faster and more numerically accurate and stable.

As a rule of thumb, if you want to do something simple, think that
there should be an easy way of doing it. And if it is something people
do every day (like taking the mean or the std of a vector, or loading
from a txt file), there should be a very easy way of doing it. :slight_smile: And
it would probably be faster and more flexible than any naive
implementation.

Good luck with your galaxies!

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222788.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

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, surfcast23 <surfcast23@...287...> wrote:

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, surfcast23 <surfcast23@...287...> 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 should be an scalar:

sigma = np.sqrt((1./len(C))*(diff**2))

should be

sigma = np.sum(np.sqrt((1./len(C))*(diff**2))) # The sum of the
previous

But, much better, you can change the three lines of code by:

avg=np.mean(C)
sigma=np.std(C)

They are way faster and more numerically accurate and stable.

As a rule of thumb, if you want to do something simple, think that
there should be an easy way of doing it. And if it is something people
do every day (like taking the mean or the std of a vector, or loading
from a txt file), there should be a very easy way of doing it. :slight_smile: And
it would probably be faster and more flexible than any naive
implementation.

Good luck with your galaxies!

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222788.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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 make both
areas fit:

plt.plot(bins, N* 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, surfcast23 <surfcast23@...287...> wrote:

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, surfcast23 <surfcast23@...287...> >>> 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 should be an scalar:

sigma = np.sqrt((1./len(C))*(diff**2))

should be

sigma = np.sum(np.sqrt((1./len(C))*(diff**2))) # The sum of the
previous

But, much better, you can change the three lines of code by:

avg=np.mean(C)
sigma=np.std(C)

They are way faster and more numerically accurate and stable.

As a rule of thumb, if you want to do something simple, think that
there should be an easy way of doing it. And if it is something people
do every day (like taking the mean or the std of a vector, or loading
from a txt file), there should be a very easy way of doing it. :slight_smile: And
it would probably be faster and more flexible than any naive
implementation.

Good luck with your galaxies!

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context:
http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222788.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222969.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Yes. I am multipliying the width of the bins by their total height.
Surely there are cleaner and more general ways
(say, when the bins are of different width), but this one does the
trick for most cases.

And, if you have many data points, you can increase the number of bins
(typically the square root of the number of points, if you have enough
density) and get a more precise profile. In that case you would want
to change the parameter of hist histype='stepfilled'

···

On Sat, Jul 28, 2012 at 12:22 AM, surfcast23 <surfcast23@...287...> wrote:

Am I reading (bins[1]-bins[0]) correctly as taking the difference between
what is in the second and first bin?

Thank you for the help!

Daπid wrote:

···

On Sat, Jul 28, 2012 at 12:22 AM, surfcast23 <surfcast23@...287...> 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 ways
(say, when the bins are of different width), but this one does the
trick for most cases.

And, if you have many data points, you can increase the number of bins
(typically the square root of the number of points, if you have enough
density) and get a more precise profile. In that case you would want
to change the parameter of hist histype='stepfilled'

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34223136.html
Sent from the matplotlib - users mailing list archive at Nabble.com.