bins and histograms

Andrea Crotti <andrea.crotti.0@...287...> writes:

values = { (0,10) : 0.5,
          (10, 20) : 0.3 }
and so on, where the key is a time slot interval and the value is the
value I want to plot.

What should be the correct way to get what I want?

Something like this perhaps:

    left, width = zip(*[(a, b-a) for (a,b) in values.keys()])
    bar(left, values.values(), width)

That is, turn the sequence of intervals into a sequence of coordinates
where the bars should start (left) and another sequence of bar widths.
Then use bar to plot the values.

In theory the data that I want to plot is [0.5, 0.3]
but if I do


The hist function not only plots the histogram bars but computes them
from the data. Use bar when you already have the coordinates you want to


Jouni K. Sepp�nen