Package trunk :: Package BIP :: Package Viz :: Module ascii :: Class Histogram
[hide private]

Class Histogram

source code

object --+
         |
        Histogram

Ascii histogram
Instance Methods [hide private]
 
__init__(self, data, bins=10, rnge=None)
Class constructor
source code
 
horizontal(self, height=4, character='|')
Returns a multiline string containing a a horizontal histogram representation of self.data
source code
 
vertical(self, height=20, character='|')
Returns a Multi-line string containing a a vertical histogram representation of self.data
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, data, bins=10, rnge=None)
(Constructor)

source code 
Class constructor
Parameters:
  • data - : array like object
  • bins - : int or sequence of scalars, optional. If bins is an int, it defines the number of equal-width bins in the given range (10, by default). If bins is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths.
  • rnge - : (float, float), optional. The lower and upper range of the bins. If not provided, range is simply (a.min(), a.max()). Values outside the range are ignored. Note that with new set to False, values below the range are ignored, while those above the range are tallied in the rightmost bin.
Overrides: object.__init__

horizontal(self, height=4, character='|')

source code 

Returns a multiline string containing a a horizontal histogram representation of self.data

>>> d = normal(size=1000)
>>> h = Histogram(d,bins=25)
>>> print h.horizontal(5,'|')
106            |||
              |||||
              |||||||
            ||||||||||
           |||||||||||||
-3.42                         3.09
Parameters:
  • height - : Height of the histogram in characters
  • character - : Character to use

vertical(self, height=20, character='|')

source code 

Returns a Multi-line string containing a a vertical histogram representation of self.data

>>> d = normal(size=1000)
>>> Histogram(d,bins=10)
>>> print h.vertical(15,'*')
                      236
-3.42:
-2.78:
-2.14: ***
-1.51: *********
-0.87: *************
-0.23: ***************
0.41 : ***********
1.04 : ********
1.68 : *
2.32 :
Parameters:
  • height - : Height of the histogram in characters
  • character - : Character to use