Exercises
This is the data that will be used in the following exercises.
-
Import
matplotlib.pyplot
asplt
and set%matplotlib inline
if you are using the jupyter notebook. What command do you use to show a plot if you aren't using the jupyter notebook? -
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 axisax
. - Plot (x,y) on that axes and set the labels and titles to match the plot shown.
- Create a figure object called fig using
-
Complete the following:
- Create a figure object and put two axes on it, ax1 and ax2. Located at
[0,0,1,1]
and[0.2,0.5,0.2,0.2]
respectively.
- Now plot (x,y) on both axes. And call your figure object to show it.
- Create a figure object and put two axes on it, ax1 and ax2. Located at
-
Complete the following:
- Create the plot below by adding two axes to a figure object at [0,0,1,1] and [0.2,0.5,0.4,0.4].
- Now use x,y, and z arrays to recreate the plot below. Notice the x limits and y limits on the inserted plot.
- Create the plot below by adding two axes to a figure object at [0,0,1,1] and [0.2,0.5,0.4,0.4].
-
Complete the following:
- Use
plt.subplots(nrows=1, ncols=2)
to create the plot below.
- Now plot (x,y) and (x,z) on the axes. Play around with the
linewidth
andstyle
.
- See if you can resize the plot by adding the
figsize()
argument inplt.subplots()
are copying and pasting your previous code.
- Use
-
Plot (x,y) and (x,z) on the same axes and style with xkcd. Add text to match the following plot.