#### 您當前位置：首頁 >> Java編程Java編程

###### 日期：2019-05-02 10:38

Exercise 4: Matplotlib

Due: 5pm Sunday Feb 4, 2018

Problem 1: US age distribution?

Read the US age distribution file (US_age_distribution.csv). The file is a plain text file that looks something like this.

year,0-14 years,15-64 years,65 years+

2005,20.43,67.25,12.32

2006,20.37,67.24,12.39

2007,20.24,67.27,12.49

...

After reading the data into lists (using csv module), make the following plots.

time series of each group as a line chart

time series of each group as a bar chart

time series of these groups as a stack chart

a pie chart for the distribution at 2015

In [1]:

Problem 2: Population height

Base on the country_population_temperature_height.csv file,

create a scatter plot to examine if there is a relationship between population and the average height

create a scatter plot to examine if there is a relationship between the average height and the average annual temperature of each country

modify the scatter plot created in 2 to also include and present the population information in the scatter plot. (Hint: you can use different color or marker size to present population).

In [2]:

Problem 3: Plot hurricane tracks

Based on data in the 2016_hurricane.csv file, use basemap to plot the tracks of all tropical storms during the 2016 hurricane season in the Atlantic basin. Make sure you use the proper map projection to have minimal distortion over the region.

This document provides the detailed description about the format of the data.

use different color to indicate the intensity of the storm: TD, TS, HU. Ignore other categories

label each track by the name of the storm.

Hints:

What basemap function should you use to make the plot?

How do you use different colors based on hurricane intensity?

This csv files contains multiple tropical storm data, so there are many header lines that are different from the data lines. How do you read this data so that you won't mix up the storms.

In [3]: