text: )
  8 comments:
  This is pretty neat. Why did you choose GPL though? Why not let proprietary users use it?
  You might want to check
  It is implemented in R. For example, using 100 Normal random variables you get:
  > stem(rnorm(100))
  The decimal point is at the |
  -2 | 31
  -1 | 9877
  -1 | 443332110000
  -0 | 9988877766655
  -0 | 4433333221100
  0 | 000111111111222222333444
  0 | 55556666777799
  1 | 001122233334
  1 | 555
  2 | 023
  @jsalvati: because proprietary developers don't give back to the community.
  @Adrian: I was refering to Python, not R. But I still think my histogram looks nicer than R's stem plot.
  Looks great. Maybe you should mention it on the scipy/numpy forums, am sure they would like to integrate it.
  Thank you so much for posting this.
  I had to make a few changes so it would for me:
  * import numpy
  * import math
  * use float() to get floating-point division
  here's the result of a diff with --unified=2
  --- histogram.py 2010/10/19 17:03:11 1.1
  +++ histogram.py 2010/10/19 17:42:17 1.2
  @@ -9,4 +9,7 @@
  #
  #
  +import numpy as np
  +import math
  +
  class Histogram(object):
  """
  @@ -18,9 +21,10 @@
  :Parameters:
  - - `data`: array like object
  + - `data`: array-like object
  + - `bins`: number of bins (default 10)
  """
  self.data = data
  self.bins = bins
  - self.h = histogram(self.data, bins=self.bins)
  + self.h = np.histogram(self.data, bins=self.bins)
  def horizontal(self, height=4, character ='|'):
  """Returns a multiline string containing a
  @@ -40,5 +44,5 @@
  """
  his = """"""
  - bars = self.h[0]/max(self.h[0])*height
  + bars = self.h[0]/float(max(self.h[0]))*height
  for l in reversed(range(1,height+1)):
  line = ""
  @@ -48,5 +52,5 @@
  line = ' '*(len(str(max(self.h[0])))+1) #add leading spaces
  for c in bars:
  - if c >= ceil(l):
  + if c >= math.ceil(l):
  line += character
  else:
  @@ -81,5 +85,5 @@
  xl = ['%.2f'%n for n in self.h[1]]
  lxl = [len(l) for l in xl]
  - bars = self.h[0]/max(self.h[0])*height
  + bars = self.h[0]/float(max(self.h[0]))*height
  his += ' '*(max(bars)+2+max(lxl))+'%s\n'%max(self.h[0])
  for i,c in enumerate(bars):
  is there really no way to format a comment with a fixed-width font?
  Could you be specific about which version or versions of the GPL you intend? Thanks!
  I like your post; it definitely beats looking a histogram as a list of numbers!
  I ran into a compatibility problem with older versions of python (2.6 for me but should manifest in anything without future division). The line
  bars = self.h[0]/max(self.h[0])*height
  could be changed to
  bars = self.h[0]*height/max(self.h[0])
  (i.e. do the multiplication before the division) in order to not lose precision from integer division.