Contents

Chapter 1

Choosing the Right Chart

Decision framework for selecting the most effective visualization for your data and message.

Quick Decision Tree

What are you showing?
│
├── COMPARISON between groups
│   ├── Few categories (2-5) → Bar chart (vertical)
│   ├── Many categories (6+) → Bar chart (horizontal)
│   ├── Over time → Line chart (grouped)
│   └── Part of whole → Stacked bar or pie (only if 2-5 segments)
│
├── DISTRIBUTION of values
│   ├── Single variable → Histogram + KDE
│   ├── Compare distributions → Box plot or violin plot
│   ├── Exact percentiles matter → Box plot
│   └── Shape matters → Violin plot or ridgeline
│
├── RELATIONSHIP between variables
│   ├── Two numeric → Scatter plot + regression line
│   ├── Numeric vs categorical → Strip/swarm plot
│   ├── Many numeric pairs → Pair plot or correlation heatmap
│   └── Three variables → Scatter with color/size encoding
│
├── TREND over time
│   ├── One metric → Line chart
│   ├── Multiple metrics → Multi-line or small multiples
│   ├── Cumulative → Area chart
│   └── Seasonal patterns → Seasonal decomposition plot
│
└── COMPOSITION
    ├── At one point in time → Pie chart (≤5 segments) or treemap
    ├── Over time → Stacked area
    └── Hierarchical → Treemap or sunburst

Rules of Thumb

SituationBest ChartAvoid
Comparing exact valuesBar chartPie chart
Showing trendLine chartBar chart
Showing distributionHistogramBar chart
CorrelationsScatter plotTable
Part-of-whole (≤5 parts)Pie/donutBar chart (sometimes)
Part-of-whole (>5 parts)TreemapPie chart
Before/after comparisonPaired bar or slope chartGrouped bars
Geographic dataChoropleth mapBar chart by region

Common Anti-Patterns

1. Dual Y-axes — Almost always misleading. Use small multiples instead.

2. 3D charts — Never add depth for decoration. It distorts perception.

3. Pie charts with >5 segments — Humans can't accurately compare angles.

4. Truncated Y-axis without indication — Either start at 0 or clearly mark the break.

5. Rainbow color schemes — Use sequential (light→dark) for ordered data, categorical for groups.

Color Guidelines

  • Sequential data (low→high): Use single-hue gradient (light blue → dark blue)
  • Diverging data (negative↔positive): Use two-hue gradient (red ← white → blue)
  • Categorical data: Use distinct hues with similar saturation
  • Highlighting: Use gray for context, color for focal point
  • Accessibility: Always check with colorblind simulation (use viridis for safe default)
Chapter 2

Statistical Tests Cheatsheet

When to use which test, what assumptions to check, and how to interpret results.

Decision Matrix

QuestionData Type# GroupsNormal?Test
Are two means different?Continuous2YesStudent's t-test
Are two means different?Continuous2NoMann-Whitney U
Are 3+ means different?Continuous3+YesOne-way ANOVA
Are 3+ means different?Continuous3+NoKruskal-Wallis
Are proportions different?Binary2N/AZ-test for proportions
Are categories associated?Categorical2+N/AChi-square test
Is there a linear relationship?Continuous × 2N/AYesPearson correlation
Is there a monotonic relationship?Ordinal/ContinuousN/ANoSpearman correlation
Before/after same subjects?Continuous2 (paired)YesPaired t-test
Before/after same subjects?Continuous2 (paired)NoWilcoxon signed-rank

Assumption Checks

Normality

  • Visual: Q-Q plot, histogram with normal curve overlay
  • Formal: Shapiro-Wilk (n<5000), D'Agostino-Pearson (any n)
  • Rule of thumb: For n>30, CLT makes t-test robust to non-normality

Equal Variance (Homoscedasticity)

  • Visual: Spread of box plots should be similar
  • Formal: Levene's test
  • Fix if violated: Use Welch's t-test (default in most software)

Independence

  • Design-based: Ensure observations are independent by study design
  • Check: No repeated measures from same subject in different groups

Effect Sizes

TestEffect SizeSmallMediumLarge
t-testCohen's d0.20.50.8
ANOVAEta-squared0.010.060.14
Chi-squareCramer's V0.10.30.5
Correlationr0.10.30.5
Mann-Whitneyrank-biserial0.10.30.5

Interpreting P-values

  • p < 0.001: Very strong evidence against null
  • p < 0.01: Strong evidence
  • p < 0.05: Moderate evidence (conventional threshold)
  • p < 0.10: Weak evidence (sometimes called "marginal")
  • p > 0.10: Little to no evidence

Remember: P-value is NOT the probability the null is true. It's the probability of seeing data this extreme IF the null were true.

Multiple Comparisons

When running many tests, false positives accumulate:

  • 20 tests at α=0.05 → expect ~1 false positive
  • Bonferroni correction: α_adjusted = α / number_of_tests
  • Benjamini-Hochberg (FDR): Controls false discovery rate instead of family-wise error
  • When to apply: When you're testing many hypotheses on the same dataset

Sample Size Rules of Thumb

TestMinimum per groupIdeal per group
t-test30100+
ANOVA20 per group50+ per group
Chi-square5 expected per cell20+ per cell
Correlation30100+
Regression10-20 per predictor50+ per predictor
Python Data Analysis Toolkit v1.0.0 — Free Preview