[Matplotlib-users] bins and histograms

2011-03-10 Thread Andrea Crotti
I'm having some troubles understanding basic concepts.
Suppose I want to do something like this, given a dictionary

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?

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

plt.hist(values.values())

I don't get that, but I get 2 bars of length 1 located in that x
coordinate. So how should I proceed then?

Thanks,
Andrea

--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bins and histograms

2011-03-10 Thread Jouni K . Seppänen
Andrea Crotti andrea.crott...@gmail.com 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

 plt.hist(values.values())

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
plot.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] bins and histograms

2011-03-10 Thread Andrea Crotti
I'm having some troubles understanding basic concepts.
Suppose I want to do something like this, given a dictionary

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?

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

plt.hist(values.values())

I don't get that, but I get 2 bars of length 1 located in that x
coordinate. So how should I proceed then?

Thanks,
Andrea

--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bins and histograms

2011-03-10 Thread Roban Hultman Kramer
The hist function expects a list of values that it bins up and counts
to form the histogram (see numpy.hist). That's why it is plotting one
count for each of the values you gave it.

You already have your counts, you just want to make a step plot out of
them. Look at the drawstyle keyword of the plot function:

drawstyle: [ 'default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' ]

Hope that puts you on the right track.

-Roban

On Thu, Mar 10, 2011 at 4:18 PM, Andrea Crotti
andrea.crott...@gmail.com wrote:
 I'm having some troubles understanding basic concepts.
 Suppose I want to do something like this, given a dictionary

 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?

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

 plt.hist(values.values())

 I don't get that, but I get 2 bars of length 1 located in that x
 coordinate. So how should I proceed then?

 Thanks,
 Andrea

 --
 Colocation vs. Managed Hosting
 A question and answer guide to determining the best fit
 for your organization - today and in the future.
 http://p.sf.net/sfu/internap-sfd2d
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users