Histogram/Bar Chart Exercises

You can create histograms/bar charts with matplotlib that have the number of bars that you choose.

a) You'll be creating 3 figures in this assignment.  Create axis labels and figure title in matplotlib
b) Save those figures using plt.savefig(some-outputfile.png)
c) Upload these pictures to moe
d) Create a small webpage on moe that displays these pictures.
e) Submit the url for that webpage to the Comments-to-Teacher, and also submit the python file that creates the figures.

1. Use the random.randrange() function from the random library to create a list of 100,000 random numbers in the 100-number range between 0 and 99.

1a). Create a histogram of these numbers with 10 bars

1b) Create a histogram of these numbers with 100 bars.

2) (a little harder): Here is a CSV file of the populations of about 80,000 towns in the U.S. from Estimates by the U.S. Census:
If you had a problem reading this file on moe or on a Mac system (which is Linux underneath), it should now be fixed.  It turns out that there were several towns which had the Spanish letter "ñ" in their names, which caused the Python .split() method to cough up a hairball (not sure why, right now).  Anyway I replaced those Spanish letters with "n", and it should all work now.

Create a bar chart of the following 10 (curious) numbers.  Count the number of towns with 0 population.  Then:  count the number of towns whose population amount begins with the digit "1", count the towns whose population amount begins with digit "2", ... and finally the number whose pop. begins with "9".  Now you have 10 numbers.  We expect the counts for "1" to "9" to be about the same (towns with 0 population are probably some ghost towns??). 
Create a bar chart of those numbers.  The Examples section of the matplotlib documentation shows how to create bar charts: https://matplotlib.org/gallery/lines_bars_and_markers/categorical_variables.html#sphx-glr-gallery-lines-bars-and-markers-categorical-variables-py

BTW, isn't this interesting?  Why should there be more towns with populations whose numbers begin with "1" than with "2" than with "3".  See Benford's Law.