#9671: Improve bar chart and histogram support
---------------------------+------------------------------------------------
   Reporter:  kcrisman     |          Owner:  jason, was
       Type:  enhancement  |         Status:  needs_work
   Priority:  major        |      Milestone:  sage-4.7.1
  Component:  graphics     |       Keywords:            
Work_issues:               |       Upstream:  N/A       
   Reviewer:               |         Author:            
     Merged:               |   Dependencies:            
---------------------------+------------------------------------------------

Comment(by kcrisman):

 Note that we have `np.histogram` if you want as well.

 And `TimeSeries.histogram?`

 Also here is something random in some code of Willliam's:
 {{{
 def dist(v, b, left=float(0), right=float(pi)):
     """
     We divide the interval between left (default: 0) and
     right (default: pi) up into b bins.

     For each number in v (which must left and right),
     we find which bin it lies in and add this to a counter.
     This function then returns the bins and the number of
     elements of v that lie in each one.

     ALGORITHM: To find the index of the bin that a given
     number x lies in, we multiply x by b/length and take the
     floor.
     """
     length = right - left
     normalize = float(b/length)
     vals = {}
     d = dict([(i,0) for i in range(b)])
     for x in v:
         n = int(normalize*(float(x)-left))
         d[n] += 1
     return d, len(v)

 def graph(d, b, num=5000, left=float(0), right=float(pi)):
     s = Graphics()
     left = float(left); right = float(right)
     length = right - left
     w = length/b
     k = 0
     for i, n in d.iteritems():
         k += n
         # ith bin has n objects in it.
         s += polygon([(w*i+left,0), (w*(i+1)+left,0), \
                      (w*(i+1)+left, n/(num*w)), (w*i+left, n/(num*w))],\
                      rgbcolor=(0,0,0.5))
     return s
 }}}

 The point being that this should be unified.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9671#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to