Module 2  ·  Core Visualization with Matplotlib

Section 2: Customizing Visualizations

Colors  ·  Labels  ·  Legends  ·  Typography  ·  Axes Formatting

🎨 Colors
  • Named colors, hex codes #1f77b4, RGB tuples
  • Color psychology: blue = trust, green = growth, red = loss
  • Colorblind-friendly palettes (IBM: blue, orange, purple)
  • Conditional colors for profit/loss bar charts
🏷️ Labels & Titles
  • Specific titles: who, what, when — avoid "Sales Chart"
  • Always include units: Revenue ($M), Market Share (%)
  • Title hierarchy: 14–16 pt bold > axis labels 12 pt
  • Subtitles via ax.text() for regional or date context
📌 Legends
  • Required whenever multiple series share an axis
  • Placement: loc='best', or bbox_to_anchor outside plot
  • Styling: shadow, fancybox, title, ncol
  • Multi-column layout for 4+ series to save vertical space
🔤 Typography
  • Global defaults via plt.rcParams['font.family']
  • Recommended: Arial, Helvetica, DejaVu Sans
  • Properties: fontweight, fontstyle, color
  • Hierarchy: title 16 pt › axis labels 12 pt › ticks 10 pt › annotations 9 pt
📐 Axes & Number Formatting
  • FuncFormatter: display $1.5M, 85K, 15% on axes
  • StrMethodFormatter('{x:,.0f}') for thousand separators
  • PercentFormatter for ratio/proportion axes
  • Tick control: set_xticks, MaxNLocator, label rotation
🧪 Lab 2 — Chart Customization
  • Part A Revenue vs. Target dual-line chart (30 pts)
  • Part B Regional sales horizontal bar chart (30 pts)
  • Part C Product line multi-series comparison (25 pts)
  • Part D Conditional profit margin bars (15 pts)