Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Histogram of floating point values.

Reply
Thread Tools

Re: Histogram of floating point values.

 
 
Kurt Smith
Guest
Posts: n/a
 
      07-25-2008
On Fri, Jul 25, 2008 at 5:02 PM, aditya shukla
<> wrote:
> 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
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
D80 histogram vs histogram on computer Martin Sørensen Digital Photography 14 12-19-2007 09:41 PM
floating point problem... floating indeed :( teeshift Ruby 2 12-01-2006 01:16 AM
converting floating point to fixed point H aka N VHDL 15 03-02-2006 02:26 PM
Fixed-point format for floating-point numbers Motaz Saad Java 7 11-05-2005 05:33 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57