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 is a figure-level function in Seaborn?
A figure-level function creates a whole figure with its own axes and manages the layout automatically. It returns a FacetGrid object that can handle multiple subplots.
Click to reveal answer
beginner
What is an axes-level function in Seaborn?
An axes-level function draws a plot on a single matplotlib Axes object. It does not create a new figure or manage layout, so you can combine multiple plots manually.
Click to reveal answer
beginner
Name one example of a figure-level function and one example of an axes-level function in Seaborn.
Why would you choose a figure-level function over an axes-level function?
Use figure-level functions when you want Seaborn to handle the whole figure, including multiple subplots and layout, especially for complex visualizations with facets.
Click to reveal answer
intermediate
How can you combine multiple axes-level plots into one figure?
You create a matplotlib figure and axes manually, then call axes-level functions on each axes to draw multiple plots in the same figure.
Click to reveal answer
Which Seaborn function type automatically creates a figure and manages layout?
AMatplotlib function
BAxes-level function
CPandas plotting function
DFigure-level function
✗ Incorrect
Figure-level functions create the entire figure and handle layout automatically.
Which of these is an axes-level function in Seaborn?
Asns.boxplot()
Bsns.catplot()
Csns.relplot()
Dsns.pairplot()
✗ Incorrect
sns.boxplot() draws on a single axes and does not create a new figure.
If you want to create multiple subplots with facets, which function type should you use?
AMatplotlib scatter
BAxes-level function
CFigure-level function
DPandas plot
✗ Incorrect
Figure-level functions support facets and multiple subplots automatically.
What does an axes-level function require you to do if you want multiple plots?
ANothing, it manages layout automatically
BCreate matplotlib axes manually and plot on each
CUse pandas plotting instead
DCreate multiple figures manually
✗ Incorrect
Axes-level functions need manual axes creation to combine multiple plots.
Which object does a figure-level function return?
AFacetGrid
Bmatplotlib Axes
CDataFrame
Dnumpy array
✗ Incorrect
Figure-level functions return a FacetGrid object to manage the figure and subplots.
Explain the difference between Seaborn figure-level and axes-level functions with examples.
Think about who manages the figure and layout.
You got /4 concepts.
Describe how you would create a figure with multiple plots using axes-level functions.
Remember axes-level functions do not create figures automatically.
You got /3 concepts.
Practice
(1/5)
1. Which of the following best describes a figure-level function in Seaborn?
easy
A. It creates a complete plot including figure and axes automatically.
B. It only modifies existing axes without creating a new figure.
C. It is used to customize axis labels after plotting.
D. It requires manual creation of figure and axes before plotting.
Solution
Step 1: Understand figure-level function role
Figure-level functions in Seaborn create the entire plot including figure and axes automatically.
Step 2: Compare with axes-level functions
Axes-level functions only draw on existing axes and do not create the figure.
Final Answer:
It creates a complete plot including figure and axes automatically. -> Option A
2. Which of the following is the correct way to use an axes-level function in Seaborn on existing axes?
easy
A. sns.scatterplot(data=df, x='age', y='height')
B. sns.scatterplot(ax=ax, data=df, x='age', y='height')
C. sns.relplot(data=df, x='age', y='height')
D. sns.relplot(ax=ax, data=df, x='age', y='height')
Solution
Step 1: Identify axes-level function usage
Axes-level functions like scatterplot can accept an ax parameter to plot on existing axes.
Step 2: Check options for correct syntax
sns.scatterplot(ax=ax, data=df, x='age', y='height') correctly passes ax=ax to scatterplot, an axes-level function.
Final Answer:
sns.scatterplot(ax=ax, data=df, x='age', y='height') -> Option B
Quick Check:
Axes-level functions use ax= parameter [OK]
Hint: Axes-level functions accept ax= parameter to plot on existing axes [OK]
Common Mistakes:
Using figure-level functions with ax= parameter (not supported)
Confusing relplot (figure-level) with scatterplot (axes-level)
Omitting ax= when plotting on existing axes
3. What will the following code output?
import seaborn as sns
import matplotlib.pyplot as plt
df = sns.load_dataset('tips')
fig, ax = plt.subplots()
sns.scatterplot(data=df, x='total_bill', y='tip', ax=ax)
plt.title('Scatterplot on existing axes')
plt.show()
medium
A. A scatterplot of total_bill vs tip on a new figure with default title
B. An empty plot with no points
C. A scatterplot of total_bill vs tip on the existing axes with custom title
D. An error because scatterplot cannot accept ax parameter
Solution
Step 1: Analyze code creating figure and axes
The code creates a figure and axes with plt.subplots() and stores axes in ax.
Step 2: Understand scatterplot with ax parameter
scatterplot is axes-level and plots on the given ax. Title is set on the figure.
Final Answer:
A scatterplot of total_bill vs tip on the existing axes with custom title -> Option C
Quick Check:
Axes-level plot on existing axes = scatterplot with ax= [OK]
Hint: Axes-level plots use ax= to draw on existing axes [OK]
Common Mistakes:
Expecting scatterplot to create new figure automatically
Thinking ax= causes error with scatterplot
Assuming title applies only to figure-level plots
4. Identify the error in this code snippet:
import seaborn as sns
import matplotlib.pyplot as plt
df = sns.load_dataset('tips')
fig, ax = plt.subplots()
sns.relplot(data=df, x='total_bill', y='tip', ax=ax)
plt.show()
medium
A. plt.show() must be called before relplot
B. plt.subplots() is missing required arguments
C. DataFrame 'df' is not loaded correctly
D. relplot does not accept ax parameter; it creates its own figure
Solution
Step 1: Check relplot function parameters
relplot is a figure-level function and does not accept an ax parameter.
Step 2: Understand error cause
Passing ax=ax to relplot causes an error because it manages figure creation internally.
Final Answer:
relplot does not accept ax parameter; it creates its own figure -> Option D
Quick Check:
Figure-level functions ignore ax= and raise error if given [OK]
Hint: Figure-level functions like relplot do NOT accept ax= [OK]
Common Mistakes:
Passing ax= to figure-level functions
Confusing relplot with scatterplot usage
Assuming plt.subplots() is incorrect here
5. You want to create a figure with two different plots side by side: a histogram and a scatterplot. Which approach correctly uses Seaborn's figure-level and axes-level functions together?
hard
A. Use sns.histplot() on one axes and sns.scatterplot() on another axes created by plt.subplots().
B. Use sns.relplot() twice, each creating its own figure, then combine figures manually.
C. Use sns.histplot() with ax= parameter and sns.relplot() without ax= on the same axes.
D. Use sns.relplot() with ax= parameter for both plots on shared axes.
Solution
Step 1: Understand figure-level vs axes-level functions
relplot is figure-level and creates its own figure; histplot and scatterplot are axes-level and can plot on existing axes.
Step 2: Plan side-by-side plots
Creating subplots with plt.subplots() and plotting axes-level functions on each axes allows side-by-side plots in one figure.
Step 3: Evaluate options
Use sns.histplot() on one axes and sns.scatterplot() on another axes created by plt.subplots(). correctly uses axes-level functions on subplots. Options A, B, and D misuse figure-level functions or ax= parameter.
Final Answer:
Use sns.histplot() on one axes and sns.scatterplot() on another axes created by plt.subplots(). -> Option A