470,810 Members | 1,244 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Re: Histogram of floating point values.

On Fri, Jul 25, 2008 at 5:02 PM, aditya shukla
<ad**************@gmail.comwrote:
Hello folks,

I have a list say

data=[0.99,0.98,0.98,0.98,0.97,0.93,0.92,0.92,0.83,0.66, 0.50,0.50]

i am trying to plot histogram of these values

i have installed numpy and matplotlib and this is what i am doing*
import numpy
import pylab
from numpy import *
from pylab import *

input_hist=array(data)
pylab.hist(input_hist,bins=0.1)
and this is the error that i am getting

(array([], dtype=int32), array([ 0.5]), <a list of 0 Patch objects>)
does this mean that i cannot plot a histogram of floating point values ? or
is there a way around
the 'bins' argument to pylab.hist() is supposed to be an integer or a
list of the bins' lower edges. The default value is 10, more than
that gives smaller bins, as one would expect. Take a look at the
pylab.hist documentation (you can do 'print pylab.hist.__doc__' from
the command interpreter).

You should have no problem plotting a hist of floats. Try this:

import numpy
import pylab
from numpy import *
from pylab import *

data=[0.99,0.98,0.98,0.98,0.97,0.93,0.92,0.92,0.83,0.66, 0.50,0.50]

input_hist=array(data)
pylab.hist(input_hist)
pylab.show()

The last line will display the actual histogram. See the difference
pylab.show and pylab.ion functions.

In the future, it is advisable to post these questions to the
matplotlib or the numpy/scipy users mailing lists.

Kurt
>
Thanks in advance

Aditya

--
http://mail.python.org/mailman/listinfo/python-list
Jul 25 '08 #1
0 1283

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by bleh | last post: by
2 posts views Thread by kevin parks | last post: by
5 posts views Thread by Anton Noll | last post: by
687 posts views Thread by cody | last post: by
15 posts views Thread by michael.mcgarry | last post: by
12 posts views Thread by KraftDiner | last post: by
7 posts views Thread by thisismyidentity | last post: by
reply views Thread by Terry Reedy | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.