In Class: Matplotlib


In [2]:
import numpy as np
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
z = np.cos(x)

Plot 'y' and 'z'

  • Create a 2x2 grid of plots
  • Plot y and z in the first row
    • y in red
    • z in blue
  • Plot y and z in the second row
    • y from $[ 0 .. \pi]$
    • y red circles only (no lines)
    • Restrict the y-axis range to the relavant values
    • z from $[ \pi/2 .. 3\pi/2]$
    • z blue triangles with lines connecting them
  • Label plot axis
  • Label plots

In [ ]: