Matplotlib: Difference between revisions

1,885 bytes removed ,  7 years ago
Line 9:
Very nice site!
 
Very nice site!
==Bonus exercises==
 
=== 1. Letter frequency analysis of the US Constitution ===
 
# Run <code>python constitution.py</code>. It will generate a bar chart showing the frequency of each letter in the alphabet in the US Constitution.
# Open and read through <code>constitution.py</code>. The code for gathering and displaying the frequencies is a bit more complicated than the previous scripts in this projects, but try to trace the general strategy for plotting the data. Be sure to read the comments!
# Try to answer the following questions:
## On line 11, what is <code>string.ascii_lowercase</code>?
## On line 18, what is the purpose of <code>char = char.lower()</code>?
## What are the contents of <code>labels</code> after the <code>for</code> loop on line 30 completes?
## On line 41, what are the two arguments passed to <code>pyplot.xticks</code>
## On line 44, we use <code>pyplot.bar</code> instead of our usual <code>pyplot.plot</code>. What are the 3 arguments passed to <code>pyplot.bar</code>?
# We've included a mystery text file <code>mystery.txt</code>: an excerpt from an actual novel. Alter <code>constitution.py</code> to process the data in <code>mystery.txt</code> instead of <code>constitution.txt</code>, and re-run the script. What do you notice that is odd about this file? You can read more about this odd novel [http://en.wikipedia.org/wiki/Gadsby_(novel) here].
 
 
=== 2. Tour the matplotlib gallery ===
 
You can truly make any kind of graph with matplotlib. You can even create animated graphs. Check out some of the amazing possibilities, including their source code, at the matplotlib gallery: http://matplotlib.sourceforge.net/gallery.html.
 
[[File:matplotlib_gallery.png|750px]]
 
 
===Congratulations!===
 
You've read, modified, and created scripts that plot and analyze data using matplotlib. Keep practicing!
 
[[File:Fireworks.png|150px]]
[[File:Balloons.png|150px]]
Anonymous user