Seaborn Assignment– 4
Categorical Plots
Basic Questions
- Using tips, draw a barplot of average tip by day; add axis labels and title.
- From tips, draw a countplot of day; display counts on top of each bar.
- Using penguins, create a barplot of mean body_mass_g by species.
- With tips, draw a boxplot of total_bill by time (Lunch/Dinner).
- Using tips, draw a violinplot of tip by smoker.
- With penguins, make a stripplot of flipper_length_mm by species with jitter enabled.
- Using penguins, draw a swarmplot of bill_depth_mm by island.
- From tips, combine plots: boxplot of total_bill by day and overlay a stripplot.
- From tips, combine plots: violinplot of tip by sex and overlay a swarmplot.
- Using tips, make a barplot of median total_bill by day (estimator=np.median, ci=None).
- With tips, draw a countplot of size (party size) and set order ascending by category value.
- Using penguins, make a boxplot of body_mass_g by sex.
- With tips, create a violinplot of total_bill by day with inner=”quartile”.
- Using tips, draw a stripplot of tip by time; set alpha=0.7.
- With penguins, draw a swarmplot of bill_length_mm by species and reduce marker size.
- From tips, draw a barplot of average tip by smoker.
- Using tips, draw a boxplot of tip by day and rotate x-tick labels 45°.
- With penguins, create a countplot of island.
- Using tips, create a violinplot of total_bill by time and set palette to any qualitative palette.
- Save any combined plot (box + swarm) as PNG and SVG from the same figure.
Intermediate Questions
- From tips, draw a grouped barplot of mean total_bill by day with hue=”sex”.
- Using tips, draw a countplot of day with hue=”smoker” and dodge=True.
- With penguins, draw a boxplot of body_mass_g by species with hue=”sex” and a shared legend.
- Using tips, draw a violinplot of tip by day with hue=”smoker” and split=True (two halves per day).
- With tips, draw a swarmplot of total_bill by day using hue=”sex” and dodge=True.
- Using tips, combine: violinplot of tip by day (inner=None) + jittered stripplot colored by sex.
- From penguins, draw a boxenplot (if available) of flipper_length_mm by species; compare spread vs boxplot in a second axes.
- With tips, sort categories by descending mean total_bill and plot a barplot using that custom order.
- Using tips, draw a pointplot of mean tip by day with confidence intervals shown; annotate points with values.
- With tips, draw a barplot of mean tip_pct = tip/total_bill by day, hue=”sex”, and set ci=None.
- Using penguins, draw a violinplot of bill_depth_mm by island with scale=”width” and inner=”box”.
- With tips, draw a boxplot of total_bill by day and overlay swarmplot colored by smoker.
- Using tips, draw a countplot of size with hue=”time” and show normalized proportions by precomputing percentages.
- With penguins, draw a stripplot of body_mass_g by species where points are colored by sex and slightly transparent.
- Using tips, create a catplot(kind=”bar”) of mean total_bill by day with col=”time” (facet by Lunch/Dinner).
- From tips, draw a violinplot of tip by day using a diverging palette; add a horizontal line at overall median tip.
- Using penguins, draw a boxplot of bill_length_mm by species and show notches; overlay a stripplot with small jitter.
- With tips, draw a barplot of mean total_bill by sex with error bars showing standard deviation (compute and pass yerr).
- Using tips, draw a swarmplot by day with hue=”smoker”, and move the legend outside the axes using bbox_to_anchor.
- With tips, make a countplot of day ordered by decreasing frequency; label bars with percentages of total rows.
Advanced Questions
Insight Combo 1: On tips, build a 2-row figure:
Row 1: barplot of mean tip_pct by day with hue=”sex”
Row 2: violin + strip of tip_pct by day with hue=”sex”
Use a shared legend and aligned category order.
Insight Combo 2: On penguins, create a dashboard with three axes:
A: boxplot of body_mass_g by species (hue=sex)
B: swarmplot for the same mapping
C: barplot of mean body_mass_g by species × sex (grouped)
Ensure consistent palette and category ordering across all.
Advanced Ordering: For tips, compute per-day median total_bill and order categories by that median. Draw box + swarm with the custom order and annotate medians.
Split & Dodge: Using tips, draw a violinplot by day with hue=”smoker” and split=True. Overlay a stripplot with hue=”smoker” and dodge=True. Ensure legends and alphas make both readable.
Multiple Categories: From tips, create a
catplot(kind="bar")
of mean total_bill by day with hue=”sex”, and facet columns by time. Align y-limits and add a suptitle.Distribution vs Count: On tips, create a 1×2 figure:
Left: countplot of day (raw counts)
Right: barplot of proportion of smokers by day (compute proportion via groupby)
Ensure both axes are labeled for direct comparison.
Outlier Focus: With penguins, produce a violinplot of bill_depth_mm by species, inner=None. Overlay a swarmplot, then circle potential outliers beyond 1.5×IQR with annotated labels.
Custom Aggregation: Using tips, draw a barplot of the 95th percentile of total_bill by day. Compute quantile and pass the pre-aggregated DataFrame to Seaborn.
Complex Legend Management: For tips, build a box + swarm (hue=sex) and a barplot (hue=smoker) on two subplots. Create one shared legend below the figure that combines entries from both axes (proxy artists).
Publish-Ready Panel: Create a 2×2 categorical insights panel for tips:
A: grouped barplot of tip_pct by day × sex
B: box + swarm of total_bill by time × smoker
C: violin + strip of tip by day
D: countplot of size ordered by frequency
Apply consistent palette, rotated labels, tight layout, and export to PNG & PDF (300 DPI).