Learn practical skills, build real-world projects, and advance your career

alt


Matplotlib Exercises

Welcome to the exercises for reviewing matplotlib! Take your time with these, Matplotlib can be tricky to understand at first. These are relatively simple plots, but they can be hard if this is your first time with matplotlib, feel free to reference the solutions as you go along.

Also don't worry if you find the matplotlib syntax frustrating, we actually won't be using it that often throughout the course, we will switch to using seaborn and pandas built-in visualization capabilities. But, those are built-off of matplotlib, which is why it is still important to get exposure to it!

** * NOTE: ALL THE COMMANDS FOR PLOTTING A FIGURE SHOULD ALL GO IN THE SAME CELL. SEPARATING THEM OUT INTO MULTIPLE CELLS MAY CAUSE NOTHING TO SHOW UP. * **

Exercises

Follow the instructions to recreate the plots using this data:

Data

import numpy as np
x = np.arange(0,100)
y = x*2
z = x**2

** Import matplotlib.pyplot as plt and set %matplotlib inline if you are using the jupyter notebook. What command do you use if you aren't using the jupyter notebook?**

 

Exercise 1

** Follow along with these steps: **

  • ** Create a figure object called fig using plt.figure() **
  • ** Use add_axes to add an axis to the figure canvas at [0,0,1,1]. Call this new axis ax. **
  • ** Plot (x,y) on that axes and set the labels and titles to match the plot below:**