In [3]:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

Homework 4

Copy this notebook. Rename it as: YOURNAME-HW4-matplotlib-XX

with your name replacing YOURNAME and the xx replaced with the date you submit or copy this HW.

.

Upload your completed jupyter notebook to elearning site in a zip labeled with your name, as a minimum something like YOURNAME-HW4.zip Do not put this notebook on your github.

Couple of reference site:

  • http://matplotlib.org/examples/pylab_examples/
  • http://docs.scipy.org/doc/numpy/

Do all the homeworks problems below: As noted doing the homework gets a 3 out of 5. To do more to create tutorials on how to create an interesting plot or set of plots that are not in this HW.

Describe what you are doing so others can follow in creating the plots.

Homework 4.1

4.1.a Create a figure with two subplots in a row. One shows a sine wave of x from with x = 0 ... 2*pi the other shows the tagent of x with the same range. Label the figures.

Should look something like:


In [ ]:

Homework 4.2

Make a combined plot of a red spiral with a scatter plot.

The red spiral has r from 0 to 3 with steps of 0.1 and a theta of 2 pi r.

The scatter uses the same theta as the spiral but the radius r is offset by a random value ranging from -.5 to .5. The size of the plotted locations is 100 * r^2 and the color uses theta.

Use an alpha value of .4 for the colors in the scatter plot. Limit the size of the plot (rmax) to 2.5

Should look something like:


In [ ]:

Homework 4.3

Create a 2d histogram of 100000 points

x is a generated from a normal random distribution

y is generated from a geometric random value witha p=.01 Use the LogNorm color settings for hist2d. And show the colorbar as well.

Should look something like:


In [ ]:

Homework 4.4

Show the same data in homewowrk 4.3 in a 3d plot. Use a numpy.histrogram2d funtion to generate the data: http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html

Need to use statements:

from mpl_toolkits.mplot3d import Axes
fig = plt.figure()
ax = fig.gca(projection='3d')

...

ax.plot_surface(xm,ym,hist,rstride=1,cstride=1,cmap=plt.cm.jet)

</em>

Should look something like:


In [ ]:


In [ ]: