histograms : xmax

Hello,

two days ago Sebastian helped me to finish in a hurry a histogram with bar()

I would like now to understand how to make the plot with hist()

First of all, my data (after a massage) looks like :

···

-----------------------------------------
0.00e+00 1.00e-04 81039
1.00e-04 2.00e-04 4472
2.00e-04 3.00e-04 2033
3.00e-04 4.00e-04 1155
4.00e-04 5.00e-04 823
5.00e-04 6.00e-04 643
6.00e-04 7.00e-04 534
7.00e-04 8.00e-04 361
8.00e-04 9.00e-04 313
9.00e-04 1.00e-03 269
1.00e-03 1.10e-03 230
1.10e-03 1.20e-03 195
1.20e-03 1.30e-03 178
1.30e-03 1.40e-03 165
1.40e-03 1.50e-03 175
1.50e-03 1.60e-03 125
1.60e-03 1.70e-03 109
1.70e-03 1.80e-03 112
1.80e-03 1.90e-03 90
.
.
.
.
9.86e-02 9.87e-02 0
9.87e-02 9.88e-02 0
9.88e-02 9.89e-02 0
9.89e-02 9.90e-02 0
9.90e-02 9.91e-02 0
9.91e-02 9.92e-02 0
9.92e-02 9.93e-02 0
9.93e-02 9.94e-02 0
9.94e-02 9.95e-02 0
9.95e-02 9.96e-02 1
-----------------------------------------

The bins are given by the two first number columns.

For instance, the first bin is from 0.00e+00 to 1.00e-04 and has the
number of data 81039

Then I run the following script on them:

----------------------------------------------
#!/usr/bin/env python

from pylab import *

H = load ( './histo3.dat')

h = H[:, 2] # the third column

n, bins, patches = hist(h, 997, normed=0, log=0,
facecolor='lightblue', alpha=0.75)

show()
----------------------------------------------

The number 997 is because this is the number of lines I have in my
file (and, thus, the number of bins)

But the plot is ranging between

0 - 90000 --> on x axis
0 - 1000 --> on y axis

Notice in the data file that x does not get further than 9.96e-02

So the maximum should be 0.0996 and I am getting 90000

Why is that?

What am I doing wrong?

I have tried to substitute lower-case e with E in the data file but
this did not help

Any help would be appreciated.

thanks,

Pau

Hello,

any hint about this?

If somebody wants to understand better what I mean, my data are here:

www.aei.mpg.de/~pau/histo3.dat

thanks

Pau

2009/7/8 Pau <vim.unix@...982...>:

···

Hello,

two days ago Sebastian helped me to finish in a hurry a histogram with bar()

I would like now to understand how to make the plot with hist()

First of all, my data (after a massage) looks like :

-----------------------------------------
0.00e+00 1.00e-04 81039
1.00e-04 2.00e-04 4472
2.00e-04 3.00e-04 2033
3.00e-04 4.00e-04 1155
4.00e-04 5.00e-04 823
5.00e-04 6.00e-04 643
6.00e-04 7.00e-04 534
7.00e-04 8.00e-04 361
8.00e-04 9.00e-04 313
9.00e-04 1.00e-03 269
1.00e-03 1.10e-03 230
1.10e-03 1.20e-03 195
1.20e-03 1.30e-03 178
1.30e-03 1.40e-03 165
1.40e-03 1.50e-03 175
1.50e-03 1.60e-03 125
1.60e-03 1.70e-03 109
1.70e-03 1.80e-03 112
1.80e-03 1.90e-03 90
.
.
.
.
9.86e-02 9.87e-02 0
9.87e-02 9.88e-02 0
9.88e-02 9.89e-02 0
9.89e-02 9.90e-02 0
9.90e-02 9.91e-02 0
9.91e-02 9.92e-02 0
9.92e-02 9.93e-02 0
9.93e-02 9.94e-02 0
9.94e-02 9.95e-02 0
9.95e-02 9.96e-02 1
-----------------------------------------

The bins are given by the two first number columns.

For instance, the first bin is from 0.00e+00 to 1.00e-04 and has the
number of data 81039

Then I run the following script on them:

----------------------------------------------
#!/usr/bin/env python

from pylab import *

H = load ( './histo3.dat')

h = H[:, 2] # the third column

n, bins, patches = hist(h, 997, normed=0, log=0,
facecolor='lightblue', alpha=0.75)

show()
----------------------------------------------

The number 997 is because this is the number of lines I have in my
file (and, thus, the number of bins)

But the plot is ranging between

0 - 90000 --> on x axis
0 - 1000 --> on y axis

Notice in the data file that x does not get further than 9.96e-02

So the maximum should be 0.0996 and I am getting 90000

Why is that?

What am I doing wrong?

I have tried to substitute lower-case e with E in the data file but
this did not help

Any help would be appreciated.

thanks,

Pau

hey there!

Pau wrote:

...
0.00e+00 1.00e-04 81039
1.00e-04 2.00e-04 4472
2.00e-04 3.00e-04 2033
...

The bins are given by the two first number columns.

For instance, the first bin is from 0.00e+00 to 1.00e-04 and has the
number of data 81039

hey pau!

i do not understand hist well myself, but i think it might be doing
something different from what you want. i think that if you run hist on
e.g. the numbers
100, 11, 10, 9, 0, 0, 0, 0, 0

and make 10 bins, it will give you

x y
0 5
10 3
20 0
30 0
40 0
50 0
60 0
70 0
80 0
90 0
100 1

if you histogram the data on the y-axis, there is no reason why this
should be still connected to the x-axis.

you have already a histogramm -- if you want to rebin, i guess you
should use "histogram" on the x-axis and weight with the y-data.

H = load ( './histo3.dat')
h = H[:, 2] # the third column

n, bins, patches = hist(h, 997, normed=0, log=0,
facecolor='lightblue', alpha=0.75)

0 - 90000 --> on x axis
Notice in the data file that x does not get further than 9.96e-02
So the maximum should be 0.0996 and I am getting 90000

if you pass only the third column to hist, it is a bit unfair to expect
it to know the other two :wink:

good luck,
sebastian.