0
0
Data Analysis Pythondata~20 mins

Categorical plots (boxplot, violinplot) in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Categorical Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of boxplot with grouped categories
What will be the output of the following code snippet that creates a boxplot grouped by category?
Data Analysis Python
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

data = pd.DataFrame({
    'Category': ['A', 'A', 'B', 'B', 'C', 'C'],
    'Value': [10, 15, 10, 20, 15, 25]
})
sns.boxplot(x='Category', y='Value', data=data)
plt.show()
AA boxplot with three boxes labeled A, B, C showing value distributions: A (10,15), B (10,20), C (15,25)
BA line plot connecting points (A,10), (A,15), (B,10), (B,20), (C,15), (C,25)
CA scatter plot with points at (A,10), (A,15), (B,10), (B,20), (C,15), (C,25)
DA bar chart showing sum of values for each category
Attempts:
2 left
💡 Hint
Boxplots show distribution of values grouped by categories.
data_output
intermediate
1:30remaining
Number of boxes in violinplot
Given the following data and code, how many violin shapes will appear in the plot?
Data Analysis Python
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

data = pd.DataFrame({
    'Group': ['X', 'X', 'Y', 'Y', 'Y', 'Z'],
    'Score': [5, 7, 6, 8, 7, 9]
})
sns.violinplot(x='Group', y='Score', data=data)
plt.show()
A6
B2
C1
D3
Attempts:
2 left
💡 Hint
Each unique category in 'Group' creates one violin shape.
visualization
advanced
1:30remaining
Identify the plot type from description
Which plot type best shows the distribution shape and individual data points for categories?
AViolinplot
BBoxplot
CBar plot
DScatter plot
Attempts:
2 left
💡 Hint
One plot type shows a smooth density shape and can include individual points.
🔧 Debug
advanced
1:30remaining
Error in boxplot code
What error will this code produce and why? import seaborn as sns import matplotlib.pyplot as plt sns.boxplot(x='Category', y='Value') plt.show()
Data Analysis Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.boxplot(x='Category', y='Value')
plt.show()
ANameError: name 'Category' is not defined
BValueError: x and y must be numeric
CTypeError: boxplot() missing 1 required positional argument: 'data'
DNo error, plot shows empty figure
Attempts:
2 left
💡 Hint
Seaborn needs data argument to know where to find columns.
🚀 Application
expert
2:30remaining
Choosing plot for comparing distributions with many categories
You have a dataset with 20 categories and want to compare the distribution of a numeric variable across them. Which plot is best to use and why?
ABar plot, because it shows average values clearly for many categories
BBoxplot, because it summarizes distribution with quartiles and is compact for many categories
CViolinplot, because it shows detailed distribution shape for each category clearly even with many categories
DScatter plot, because it shows all individual points for all categories
Attempts:
2 left
💡 Hint
Consider clarity and compactness when many categories exist.