Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What are small multiples (facet grids) in data visualization?
Small multiples are a series of similar graphs or charts using the same scale and axes, arranged in a grid. They help compare different subsets of data side by side clearly.
Click to reveal answer
beginner
Why use small multiples instead of one combined plot?
Small multiples separate data into smaller plots, making it easier to see patterns and differences across groups without clutter or confusion from overlapping data.
Click to reveal answer
intermediate
Which matplotlib function helps create small multiples (facet grids)?
Matplotlib itself does not have a direct facet grid function, but you can use subplots with loops or use seaborn's 'FacetGrid' which is built on matplotlib for easy small multiples.
Click to reveal answer
beginner
How do you arrange multiple plots in matplotlib to create a grid?
Use plt.subplots(nrows, ncols) to create a grid of axes, then plot each subset of data on each axis to form small multiples.
Click to reveal answer
beginner
What is a real-life example where small multiples help?
Comparing monthly sales trends for different stores side by side helps managers quickly spot which stores perform better or worse over time.
Click to reveal answer
What is the main benefit of using small multiples?
ATo combine all data into one plot
BTo compare multiple subsets of data clearly
CTo reduce the number of plots shown
DTo hide differences between groups
✗ Incorrect
Small multiples allow clear comparison of different data subsets by showing them in separate but similar plots.
Which matplotlib function is commonly used to create a grid of plots?
Aplt.subplots()
Bplt.plot_grid()
Cplt.grid()
Dplt.facetgrid()
✗ Incorrect
plt.subplots() creates a grid of axes where you can plot multiple charts side by side.
Which library provides a direct FacetGrid function built on matplotlib?
Aseaborn
Bpandas
Cnumpy
Dscikit-learn
✗ Incorrect
Seaborn offers FacetGrid, which simplifies creating small multiples using matplotlib.
Small multiples help to avoid which common problem in data visualization?
AChanging axis labels
BUsing too many colors
CAdding legends
DOverlapping data points
✗ Incorrect
By splitting data into multiple plots, small multiples reduce clutter and overlapping points.
If you want to compare sales trends for 4 regions, how would small multiples help?
AShow only the top region's sales
BShow all regions in one plot with different colors
CCreate 4 separate plots arranged in a grid, one per region
DCombine all data into a single number
✗ Incorrect
Small multiples create separate plots for each region, making it easier to compare trends visually.
Explain what small multiples (facet grids) are and why they are useful in data visualization.
Think about how showing many small charts side by side helps compare groups.
You got /3 concepts.
Describe how you would create a small multiples grid using matplotlib for different categories in your data.
Consider how to arrange multiple plots and assign data to each.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of using small multiples (facet grid) in matplotlib?
easy
A. To display multiple related charts side by side for easy comparison
B. To create a single large plot with multiple lines
C. To animate a plot over time
D. To change the color scheme of a plot
Solution
Step 1: Understand the concept of small multiples
Small multiples are multiple small charts arranged in a grid to compare different groups or categories easily.
Step 2: Identify the purpose in matplotlib
Matplotlib uses small multiples to show many charts side by side, making it easier to compare data visually.
Final Answer:
To display multiple related charts side by side for easy comparison -> Option A
Quick Check:
Small multiples = multiple charts side by side [OK]
Hint: Small multiples = many small charts for comparison [OK]
Common Mistakes:
Confusing small multiples with animations
Thinking it changes colors only
Assuming it creates one big plot
2. Which of the following is the correct way to create a 2x2 grid of subplots in matplotlib?
easy
A. fig, axes = plt.subplots(4)
B. fig, axes = plt.subplots(1, 4)
C. fig, axes = plt.subplots(2, 2)
D. fig, axes = plt.subplots(2)
Solution
Step 1: Recall plt.subplots() syntax
plt.subplots(rows, columns) creates a grid of subplots with given rows and columns.
Step 2: Match the grid size
To create a 2x2 grid, use plt.subplots(2, 2).
Final Answer:
fig, axes = plt.subplots(2, 2) -> Option C
Quick Check:
plt.subplots(2, 2) = 2 rows and 2 columns [OK]
Hint: Use plt.subplots(rows, columns) for grid size [OK]
Common Mistakes:
Using single number for grid shape
Confusing rows and columns
Missing one dimension in arguments
3. What will be the output of this code snippet?
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, 3)
data = [1, 2, 3]
for i, ax in enumerate(axes):
ax.plot([data[i]] * 3)
plt.show()
medium
A. Three line plots each with three points of the same value 1, 2, and 3 respectively
B. A single plot with three lines of values 1, 2, and 3
C. Error because axes is not iterable
D. Three scatter plots with points 1, 2, and 3
Solution
Step 1: Understand plt.subplots(1, 3)
This creates 1 row and 3 columns of subplots, so axes is an array of 3 axes objects.
Step 2: Loop plots each subplot
For each axis, it plots a line with three points all equal to data[i] (1, then 2, then 3).
Final Answer:
Three line plots each with three points of the same value 1, 2, and 3 respectively -> Option A
Quick Check:
Loop over axes plots lines with repeated values [OK]
Hint: Loop over axes to plot each subplot separately [OK]
Common Mistakes:
Thinking axes is a single plot
Assuming error due to axes type
Confusing line plot with scatter plot
4. Identify the error in this code for creating a 2x2 grid of plots:
fig, axes = plt.subplots(2, 2)
for i in range(4):
axes[i].plot([1, 2, 3])
plt.show()
medium
A. The plot data list is invalid
B. plt.subplots(2, 2) creates only 2 plots, not 4
C. plt.show() is missing
D. axes is a 2D array, so axes[i] indexing causes an error
Solution
Step 1: Understand axes shape from plt.subplots(2, 2)
axes is a 2x2 numpy array of Axes objects, not a flat list.
Step 2: Identify indexing error
axes[i] tries to index a 2D array with one index, causing an error. Correct is axes[row, col] or flatten axes first.
Final Answer:
axes is a 2D array, so axes[i] indexing causes an error -> Option D
Quick Check:
2D axes need two indices or flatten before looping [OK]
Hint: 2D axes need two indices or flatten before indexing [OK]
Common Mistakes:
Assuming axes is 1D array
Ignoring error from wrong indexing
Thinking plt.show() is missing
5. You have a dataset with sales data for 3 regions. How would you create a 1-row, 3-column grid of plots showing sales trends for each region separately using matplotlib?
hard
A. Use plt.plot() three times without subplots
B. Use plt.subplots(1, 3), loop over axes, and plot each region's data on each subplot
C. Use plt.subplots(3, 1) and plot all regions on each subplot
D. Use plt.subplots(1, 1) and plot all regions on the same plot
Solution
Step 1: Create a 1x3 grid for three regions
Use plt.subplots(1, 3) to create one row and three columns of plots.
Step 2: Loop over axes and plot each region's data
Loop through each axis and plot the sales data for each region separately to compare trends side by side.
Final Answer:
Use plt.subplots(1, 3), loop over axes, and plot each region's data on each subplot -> Option B
Quick Check:
One row, three columns, loop to plot each region [OK]
Hint: Create grid then loop axes to plot groups separately [OK]