[Numpy-discussion] help creating a reversed cumulative histogram
Wed Sep 2 18:55:03 CDT 2009
On Wed, Sep 2, 2009 at 7:26 PM, Robert Kern<firstname.lastname@example.org> wrote:
> On Wed, Sep 2, 2009 at 18:15, Tim Michelsen<email@example.com> wrote:
>> 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.
> Okay. That is completely different from what you've asked before.
>> 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.
>> sums = np.histogram(values, weights=values,
>> ecdf_sums = np.hstack([0.0, sums.cumsum() ])
>> ecdf_inv_sums = ecdf_sums[::-1]
> This is not the kind of "inversion" that you are looking for. You want
> ecdf_inv_sums = ecdf_sums[-1] - ecdf_sums
and you can plot the histogram with bar
eisf_sums = ecdf_sums[-1] - ecdf_sums # empirical inverse survival
function of weights
width = sums - sums
rects1 = plt.bar(sums, eisf_sums, width, color='b')
Are you sure you want cumulative weights in the histogram?
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> NumPy-Discussion mailing list
More information about the NumPy-Discussion