CSCE 110 — Programming IPlotting Nathan’s Hot Dog Contest ResultsDr. Tiffani L. WilliamsDepartment of Computer Science and EngineeringTexas A&M UniversityFall 2011Nathan’s Hot Dog Eating ContestIThe Nathan’s Hot Dog Eating Contest is an annual Americancompetitive-eating competition held on July 4th at Nathan’sFamous restaurant in Coney Island.ISince it is a sporting event, ESPN has televised thecompetition live since 2004.IBesides free hot dogs and Pepto Bismal, the competitors canalso win cash prizes.IFirst Place: $10,000ISecond Place: $5,000IThird Place: $2,500IFourth Place: $1,500IFifth Place: $1,000IIn sum, a disgusting contest that is a fun way to celebrateIndependence Day in the United States. ,MotivationIAll data that we will use in our plots is available fromWikipedia.IAlso, there are links in the slides for obtaining the data fromNathan Yau, the author who wrote an interesting book called“Visualize This: The FlowingData Guide to Design,Visualization, and Statistics.”IIn Yau’s book, he presented a neat visualization example usingNathan’s Hot Dog Eating Contest data. His work provided theinspiration to see what kinds of plots we can make in Python.IBesides, plotting data from a disgusting contest is fun. ,Here’s our data. I(Download the hot dog contest data.)1 " Year " , " Win n er " ," Hot dog s eat en " ," C ount r y " , " Con test dur a tion "2 1980 , " Pa ul Sie d erman & Joe B aldi ni " ,9.1 , " Uni t ed Sta tes " ,103 1981 , " Tho mas DeB erry " ,11 , " U nit e d S tat es " ,104 1982 , " Ste ven Ab r ams " ,11 , " U nit e d Stat es " ,105 1983 , " Lu is Ll amas " ,19.5 , " M exic o " ,106 1984 , " Bir git Fe l den " ,9.5 , " G erma n y " ,107 1985 , " Os car Rod r iguez " ,11.75 , " U n ite d S tate s " ,108 1986 , " Ma rk He ller " ,15.5 , " U nite d S tate s " ,109 1987 , " D on W o lfm a n " ,12 , " Uni t ed Sta tes " ,1210 1988 , " J ay G ree n " ,14 , " Uni ted Sta tes " ,1211 1989 , " J ay G ree n " ,13 , " Uni ted Sta tes " ,1212 1990 , " Mi ke De Vito " ,16 , " U nit ed Stat es " ,1213 1991 , " Fr ank Del l arosa " ,21.5 , " U n ite d S tate s " ,1214 1992 , " Fr ank Del l arosa " ,19 , " U nit e d S tat es " ,1215 1993 , " Mi ke De Vito " ,17 , " U nit ed Stat es " ,1216 1994 , " Mi ke De Vito " ,20 , " U nit ed Stat es " ,1217 1995 , " Edw ard Kra chie " ,19.5 , " U n ite d S tate s " ,1218 1996 , " Edw ard Kra chie " ,22.25 , " U n ite d S tate s " ,1219 1997 , " Hir o fumi Nak a jima " ,24.5 , " J apa n " ,1220 1998 , " Hir o fumi Nak a jima " ,19 , " J apa n " ,1221 1999 , " St eve Ke i ner " ,20.25 , " U nite d S tate s " ,1222 2000 , " Kaz u toyo Arai " ,2 5.13 , " J apa n " ,1223 2001 , " Tak eru Kob a y ashi " ,50 , " J apa n " ,1224 2002 , " Tak eru Kob a y ashi " ,50.5 , " J apan " ,1225 2003 , " Tak eru Kob a y ashi " ,44.5 , " J apan " ,1226 2004 , " Tak eru Kob a y ashi " ,53.5 , " J apan " ,12Here’s our data. II27 2005 , " Tak eru Kob a y ashi " ,49 , " J apa n " ,1228 2006 , " Tak eru Kob a y ashi " ,53.75 , " J apan " ,1229 2007 , " Jo ey Che s tnut " ,66 , " U nit e d Stat es " ,1230 2008 , " Jo ey Che s tnut " ,59 , " U nit e d Stat es " ,1031 2009 , " Jo ey Che s tnut " ,68 , " U nit e d Stat es " ,1032 2010 , " Jo ey Che s tnut " ,54 , " U nit e d Stat es " ,1033 2011 , " Jo ey Che s tnut " ,62 , " U nit e d Stat es " ,10 A line plot(Download the Python code to make a line plot.)Listing 1: plot-nathans-hotdog-results-lineplot.py1 # Maki ng a l ine plo t for the resu lts fr om Na t han ’s Hot Dog C onte s t .23 i mpor t m a t plot l i b . pyp lot as plot4 i mpor t n ump y as np56 def m a k e _line_ p l o t ( years , hotd o g s_eate n ):78 # crea te can v as f or f igur e9 fig = pl ot . figu re ( f i gsiz e =(10 ,5))1011 # set up init ial lab els a nd w idt h of bar plot12 x_l a b el_po s = rang e ( len ( ye ars ))1314 # crea te bar pl ot15 p lot . pl ot ( x_l abel _po s , hotd ogs_ eate n , col or = ’ blue ’ , m ark e r = ’o ’)1617 # add forma t ting to bar plo t18 p lot . ti tle ( " Nath an ’s Hot dog Con t est Res u lts " )19 p lot . xla bel ( " Yea r ")20 p lot . yla bel ( " N umb e r of hotd ogs eat en " )21 p lot . gr id ( True )2223 # x _labe l _ pos is a num py arr ay . Sup pose x_l a b el_po s is arra y ([0 , 1 ,2 ,3]).24 # Supp o se we w ant to add the val ue 0 .5 to eac h valu e in the x_lab e l _pos25 # arr ay . We can s impl y writ e x _ labe l _ pos + 0.5 w hic h wil l r esu lt in26 # arr ay ([0.5 , 1.5 , 2.5 , 3.5] ). Thus , num py arr ays give us a lot of power27 # to manip u late arr ays wi th u sing for or whi le loo ps .28 p lot . xti cks ( x _la bel _pos , year s )2930 # sca le ax es31 p lot …
View Full Document