Seaborn Assignment– 4

Categorical Plots

Basic Questions

  1. Using tips, draw a barplot of average tip by day; add axis labels and title.
  2. From tips, draw a countplot of day; display counts on top of each bar.
  3. Using penguins, create a barplot of mean body_mass_g by species.
  4. With tips, draw a boxplot of total_bill by time (Lunch/Dinner).
  5. Using tips, draw a violinplot of tip by smoker.
  6. With penguins, make a stripplot of flipper_length_mm by species with jitter enabled.
  7. Using penguins, draw a swarmplot of bill_depth_mm by island.
  8. From tips, combine plots: boxplot of total_bill by day and overlay a stripplot.
  9. From tips, combine plots: violinplot of tip by sex and overlay a swarmplot.
  10. Using tips, make a barplot of median total_bill by day (estimator=np.median, ci=None).
  11. With tips, draw a countplot of size (party size) and set order ascending by category value.
  12. Using penguins, make a boxplot of body_mass_g by sex.
  13. With tips, create a violinplot of total_bill by day with inner=”quartile”.
  14. Using tips, draw a stripplot of tip by time; set alpha=0.7.
  15. With penguins, draw a swarmplot of bill_length_mm by species and reduce marker size.
  16. From tips, draw a barplot of average tip by smoker.
  17. Using tips, draw a boxplot of tip by day and rotate x-tick labels 45°.
  18. With penguins, create a countplot of island.
  19. Using tips, create a violinplot of total_bill by time and set palette to any qualitative palette.
  20. Save any combined plot (box + swarm) as PNG and SVG from the same figure.

Intermediate Questions

  1. From tips, draw a grouped barplot of mean total_bill by day with hue=”sex”.
  2. Using tips, draw a countplot of day with hue=”smoker” and dodge=True.
  3. With penguins, draw a boxplot of body_mass_g by species with hue=”sex” and a shared legend.
  4. Using tips, draw a violinplot of tip by day with hue=”smoker” and split=True (two halves per day).
  5. With tips, draw a swarmplot of total_bill by day using hue=”sex” and dodge=True.
  6. Using tips, combine: violinplot of tip by day (inner=None) + jittered stripplot colored by sex.
  7. From penguins, draw a boxenplot (if available) of flipper_length_mm by species; compare spread vs boxplot in a second axes.
  8. With tips, sort categories by descending mean total_bill and plot a barplot using that custom order.
  9. Using tips, draw a pointplot of mean tip by day with confidence intervals shown; annotate points with values.
  10. With tips, draw a barplot of mean tip_pct = tip/total_bill by day, hue=”sex”, and set ci=None.
  11. Using penguins, draw a violinplot of bill_depth_mm by island with scale=”width” and inner=”box”.
  12. With tips, draw a boxplot of total_bill by day and overlay swarmplot colored by smoker.
  13. Using tips, draw a countplot of size with hue=”time” and show normalized proportions by precomputing percentages.
  14. With penguins, draw a stripplot of body_mass_g by species where points are colored by sex and slightly transparent.
  15. Using tips, create a catplot(kind=”bar”) of mean total_bill by day with col=”time” (facet by Lunch/Dinner).
  16. From tips, draw a violinplot of tip by day using a diverging palette; add a horizontal line at overall median tip.
  17. Using penguins, draw a boxplot of bill_length_mm by species and show notches; overlay a stripplot with small jitter.
  18. With tips, draw a barplot of mean total_bill by sex with error bars showing standard deviation (compute and pass yerr).
  19. Using tips, draw a swarmplot by day with hue=”smoker”, and move the legend outside the axes using bbox_to_anchor.
  20. With tips, make a countplot of day ordered by decreasing frequency; label bars with percentages of total rows.

Advanced Questions

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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).

  10. 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).