The old Google Groups will be going away soon, but your browser is incompatible with the new version.
This is a Usenet group - learn more
Please Help with vertical histogram
 There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic. There was an error processing your request. Please try again. Standard view   View as tree
 2 messages
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful

From:
To:
Cc:
Followup To:
 Add Cc | Add Followup-to | Edit Subject
Subject:
 Validation: For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon.

More options Jul 11 2011, 8:42 pm
Newsgroups: comp.lang.python
From: Cathy James <nambo...@gmail.com>
Date: Mon, 11 Jul 2011 19:42:10 -0500
Local: Mon, Jul 11 2011 8:42 pm
Subject: Please Help with vertical histogram
Please kindly help- i have a project where I need to plot dict results
as a histogram. I just can't get the y- axis to print right.  May
someone please help?  I have pulled my hair for the past two weeks, I
am a few steps ahead, but stuck for now.

def histo(his_dict = {1:16, 2:267, 3:267, 4:169, 5:140, 6:112, 7:99,
8:68, 9:61, 10:56, 11:35, 12:13, 13:9, 14: 7, 15:2}):

x_max = 17 #get maximum value of x
y_max = 400 #get minimum value of y
# print each line
print ('^')
for j in range(y_max, 0, -100):# draw

s = '|'
for i in range(1, x_max):
if i in his_dict.keys() and his_dict[i] >= j:
s += '***'
else:
s += '   '
print (s)
print (j)
# print x axis
s = '+'
for i in range(1, x_max):
s += '-+-'
s += '>'
print (s)

# print indexes
s = ' '
for i in range(1, x_max):
s += ' %d ' % i
print (s)

histo()

# I need it to look like this:
400 -|
|
|
|
|
300 -|
|
|   ******
|   ******
|   ******
200 -|   ******
|   ******
|   *********
|   ************
|   ************
100 -|   ***************
|   ******************
|   ************************
|   ***************************
|*********************************
0 -+-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
| 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16

You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
More options Jul 12 2011, 1:50 am
Newsgroups: comp.lang.python
From: Thorsten Kampe <thors...@thorstenkampe.de>
Date: Tue, 12 Jul 2011 07:50:50 +0200
Local: Tues, Jul 12 2011 1:50 am
Subject: Re: Please Help with vertical histogram
* Cathy James (Mon, 11 Jul 2011 19:42:10 -0500)

> Please kindly help- i have a project where I need to plot dict results
> as a histogram. I just can't get the y- axis to print right. May
> someone please help? I have pulled my hair for the past two weeks, I
> am a few steps ahead, but stuck for now.

This sounds like homework. There's the Python Tutor mailing list where
you will receive help.

Thorsten

You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
 End of messages
 « Back to Discussions « Newer topic Older topic »

 Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy ©2013 Google