12 - Subplots
Channel: Aaron J Newman
Date: 2021-10-07

We learn how to make a Matplotlib figure in Python with mutiple subplots inside it. 

Summary:
- Using plt.subplots(), we can generate figures containing multiple subplots
- The number of rows and columns of subplots in a figure is set by the nrows= and ncols= kwargs, or alternatively just providing the number of rows and columns as the first arguments to plt.subplots()
- When creating a figure with subplots, it's good practice to assign the result to fig, axs rather than fig, ax, to reflect the fact that axs is an object containing all of the axes
- The different axes of a subplot are accessed (such as for drawing into, or modifying properties) using indexing, as in axs[0]
- If a figure's layout is two-dimensional (i.e., greater than 1 row and 1 column), then two-dimensional indexing is required for axes (e.g., axs[0, 1])
- The figure's overall size is set by the figsize= kwarg to plt.subplots()
- Avoid overlapping elements in subplots by running plt.tight_layout() right before plt.show()

From the course, NESC 3505 Neural Data Science, by Aaron J Newman, Dalhousie University, Halifax, NS, Canada. 

All course videos are here:  http://neuraldatascience.io/videos

Textbook is available here: http://neuraldatascience.io