[Numpy-discussion] help creating a reversed cumulative histogram
Wed Sep 2 18:15:28 CDT 2009
Hello fellow numy users,
I posted some questions on histograms recently [1, 2] but still couldn't
find a solution.
I am trying to create a inverse cumulative histogram  which shall
look like  but with the higher values at the left.
The classification shall follow this exemplary rule:
class 1: 0
all values > 0
class 2: 10
all values > 10
class 3: 15
all values > 15
class 4: 20
all values > 20
class 5: 25
all values > 25
I could get this easily in a spreadsheet by creating a matix with
conditional statements (if VALUES_COL > CLASS_BOUNDARY; VALUES_COL; '-').
With python (numpy or pylab) I was not successful. The plotted histogram
envelope turned out to be just the inverted curve as the one created
with the spreadsheet app.
I have briely visualised the issue here . I hope that this makes it
Later I would like to sum and count all values in each bin as discussed
May someone give me pointer or hint on how to improve my code below to
achive the desired histogram?
Thanks a lot in advance,
##### CODE #####
normed = False
values # loaded data as array
bins = 10
## taken from
sums = np.histogram(values, weights=values,
ecdf_sums = np.hstack([0.0, sums.cumsum() ])
ecdf_inv_sums = ecdf_sums[::-1]
More information about the NumPy-Discussion