<br>I have a histogram script in Python at <a href="http://stromberg.dnsalias.org/svn/histogram/trunk/">http://stromberg.dnsalias.org/svn/histogram/trunk/</a>  It's under a UCI (BSD-like) license.  Feel free to use it or borrow ideas from it.<br>
<br><div class="gmail_quote">On Mon, Jul 11, 2011 at 5:42 PM, Cathy James <span dir="ltr"><<a href="mailto:nambo4jb@gmail.com">nambo4jb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Please kindly help- i have a project where I need to plot dict results<br>
as a histogram. I just can't get the y- axis to print right.  May<br>
someone please help?  I have pulled my hair for the past two weeks, I<br>
am a few steps ahead, but stuck for now.<br>
<br>
<br>
def histo(his_dict = {1:16, 2:267, 3:267, 4:169, 5:140, 6:112, 7:99,<br>
8:68, 9:61, 10:56, 11:35, 12:13, 13:9, 14: 7, 15:2}):<br>
<br>
    x_max = 17 #get maximum value of x<br>
    y_max = 400 #get minimum value of y<br>
    # print each line<br>
    print ('^')<br>
    for j in range(y_max, 0, -100):# draw<br>
<br>
        s = '|'<br>
        for i in range(1, x_max):<br>
            if i in his_dict.keys() and his_dict[i] >= j:<br>
                s += '***'<br>
            else:<br>
                s += '   '<br>
        print (s)<br>
        print (j)<br>
        # print x axis<br>
    s = '+'<br>
    for i in range(1, x_max):<br>
        s += '-+-'<br>
    s += '>'<br>
    print (s)<br>
<br>
    # print indexes<br>
    s = ' '<br>
    for i in range(1, x_max):<br>
        s += ' %d ' % i<br>
    print (s)<br>
<br>
histo()<br>
<br>
# I need it to look like this:<br>
400 -|<br>
       |<br>
       |<br>
       |<br>
       |<br>
300 -|<br>
       |<br>
       |   ******<br>
       |   ******<br>
       |   ******<br>
200 -|   ******<br>
       |   ******<br>
       |   *********<br>
       |   ************<br>
       |   ************<br>
100 -|   ***************<br>
       |   ******************<br>
       |   ************************<br>
       |   ***************************<br>
       |*********************************<br>
    0 -+-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-<br>
       | 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>