0
0
Matplotlibdata~5 mins

Plt.subplots with rows and columns in Matplotlib - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does plt.subplots(rows, cols) do in matplotlib?
It creates a figure and a grid of subplots arranged in the specified number of rows and columns. You get a figure object and an array of axes to plot on.
Click to reveal answer
beginner
How do you access the subplot in the second row and first column when using plt.subplots(2, 3)?
You access it with axes[1, 0] because indexing starts at 0 and axes is a 2D array of shape (2, 3).
Click to reveal answer
beginner
What type of object is returned by plt.subplots()?
It returns a tuple: (figure, axes). figure is the whole drawing area, and axes is either a single Axes object or an array of Axes objects.
Click to reveal answer
beginner
How can you create a 1-row, 3-column subplot layout?
Use fig, axes = plt.subplots(1, 3). This creates one row with three columns of plots side by side.
Click to reveal answer
beginner
What happens if you create subplots with plt.subplots(1, 1)?
You get a single Axes object, not an array. So you can use it directly without indexing.
Click to reveal answer
What does plt.subplots(2, 2) return?
AOnly a figure object
BA figure and a 2x2 array of Axes objects
COnly a list of plots
DA figure and a single Axes object
How do you plot on the subplot in the first row, second column of plt.subplots(3, 3)?
Aaxes[0, 2]
Baxes[1, 0]
Caxes[1, 1]
Daxes[0, 1]
If you create subplots with plt.subplots(1, 1), what type is axes?
AA single Axes object
BA list
CA 2D array
DNone
What is the shape of axes when you run fig, axes = plt.subplots(4, 1)?
A(4, 1) array
B(1, 4) array
CSingle Axes object
DList of 4 figures
Which command creates a 2-row, 3-column grid of plots?
Aplt.subplots(3, 2)
Bplt.subplots(1, 6)
Cplt.subplots(2, 3)
Dplt.subplots(6, 1)
Explain how to create a grid of subplots with 2 rows and 3 columns using matplotlib and how to access the subplot in the second row, third column.
Remember indexing starts at 0 for rows and columns.
You got /4 concepts.
    Describe what happens when you create subplots with plt.subplots(1, 1) and how it differs from creating multiple subplots.
    Think about the shape and type of axes returned.
    You got /4 concepts.