We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,386 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Plotting Help

Hello All,
I'm working on my first Python plot in my programming class this week.
My assignment is to write a program to plot data contained in a csv format.
Here is the data:
"Bowl number", "Date", "Bowl location", "Winner", "Number wings eaten"
"I", "1/29/1993", "Wyndham Franklin Plaza Hotel", "Carmen ’The Beast From the East’ Cordero", 100
"II","1/28/1994", "The Main Event", "Kevin ’Heavy Keavy’ O"Donnell", 127
"III", "1/27/1995", "Club Egypt", "Kevin ’Heavy Keavy’ O"Donnell""", 133
"IV","1/26/1996","Electric Factory","Glen ’Fluffmaster’ Garrison", 155
"V", "1/24/1997", "Electric Factory", "Eric ’Gentleman E’ Behl", 120
"VI","1/23/1998","Spectrum","Mark ’Big Rig’ Vogeding", 164
"VII", "1/29/1999", "Spectrum", "Bill ’El Wingador’ Simmons", 113
"VIII", "1/28/2000", "First Union Center","’Tollman Joe’ Paul", 90
"IX","1/26/2001","First Union Center", "Bill ’El Wingador’ Simmons", 137
"X", "2/1/2002", "First Union Center", "Bill ’El Wingador’ Simmons", 135
"XI","1/2/2003","First Union Center", "Bill ’El Wingador’ Simmons",154
"XII", "1/30/2004", "Wachovia Center", "Sonya ’The Black Widow’ Thomas", 167
"XIII", "2/4/2005", "Wachovia Center", "Bill ’El Wingador’ Simmons", 162
"XIV", "2/3/2006", "Wachovia Center", "Joey Chestnut", 173
"XV","2/2/2007","Wachovia Center", "Joey Chestnut",182
"XVI", "2/1/2008", "Wachovia Center", "Joey Chestnut",241
"XVII", "1/30/2009", "Wachovia Center", "Jonathan ’Super’ Squibb",203
"XVIII", "2/5/2010", "Wachovia Center", "Cassandra ’Wings’ Gillig", 238
"XIX", "2/4/2011", "Wells Fargo Center", "Jonathan ’Super’ Squibb", 255

My x axis has to look like this "I ('93)" "II ('94)" etc.
My y axis is just the number of wings.
I have to keep my program like it is layed out for the assignemnt to
be correct, but I'm getting an error "ValueError: x and y must have
same first dimension"
There are a few other kinks in the program that I can't figure out.
This is my program so far:

import matplotlib.pyplot as plot 
import numpy as np 
def make_line_plot(wing_bowl,wings_eaten): 
    fig = plot.figure ( figsize =(20 ,5)) 
    x_label_pos = range(len(wing_bowl)) 
    plot.plot(x_label_pos, wings_eaten, color='blue', marker= 'o') 
    plot.title('Wing Bowl Contest Results') 
    plot.xlabel("Wing Bowl") 
    plot.ylabel('Number of wings eaten') 
    plot.grid('True') 
    plot.xticks(x_label_pos,wing_bowl) 
    plot.yticks(range(0,300,50)) 
    plot.autoscale(enable=True, axis='x',tight=True) 
    fig.autofmt_xdate() 
    plot.savefig('wing-bowl-results.pdf') 
def main(): 
    input_file=open('wing-bowl-data.csv') 
    input_file.readline() 
    lines=input_file.readlines() 
    wingbowl=[] 
    wings=[] 
    for line in lines: 
        split_line=line.strip().split(',') 
        wingbowl+=split_line[0] 
        wings+=[float(split_line[4])] 
    make_line_plot(wingbowl,wings) 
main()

Any help would be greatly appreciatated!
Thanks,
Joey

1
Contributor
0
Replies
1
View
Joey7
Newbie Poster
4 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0563 seconds using 2.71MB