Skip to content
elevatedevco

Cheat sheet · Data & MLOps

Making charts and data visualization cheat sheet

The key ideas on one page — plus common pitfalls and interview tips. Skim it before an interview, or print it for revision.


Cheat sheet

A dense, practitioner-focused reference on data visualization for data scientists and ML engineers: chart selection by data type, perceptual and design principles, the modern Python/JS tooling stack, statistical and ML-specific plots, and dashboarding/storytelling for production and interviews.

Foundations: Match Chart to Data + Question

  • Pick the chart from the question and data type, not aesthetics: comparison (bar), trend over time (line), distribution (histogram/KDE/box/violin/ECDF), relationship (scatter/heatmap), composition/part-to-whole (stacked bar, treemap), flow (Sankey).
  • Encoding effectiveness ranking (Cleveland & McGill, for quantitative data): position > length > angle/slope > area > volume > color saturation > color hue. Prefer position/length; treat color/area as last resorts for magnitude.
  • Measurement scale (nominal/ordinal/interval/ratio) dictates valid encodings: sequential colormap for ordered magnitude, diverging for deviation from a meaningful midpoint, qualitative palette for nominal classes.
  • Bars must start at zero (length encoding); line/scatter axes may be truncated when zero is not meaningful. Avoid dual y-axes - they imply spurious correlation and can be rescaled to tell any story.
  • Pie/donut charts are weak (angle/area perception): use only for 2-3 slices summing to a whole; otherwise a sorted horizontal bar is almost always better.
  • Aggregate vs raw: a single summary (mean/bar) can hide multimodality, outliers, and variance - Anscombe's quartet and the Datasaurus Dozen have near-identical summary stats with wildly different shapes. Plot the distribution.

Perception & Design Principles

  • Data-ink ratio (Tufte): maximize ink that encodes data; remove chartjunk (heavy gridlines, 3D, gradients, redundant legends) so the signal reads faster.
  • Pre-attentive attributes (color, size, orientation, position) are processed in well under a second - use exactly one to highlight the key insight; overusing them creates visual noise.
  • Color accessibility: ~8% of men (and ~0.5% of women) have red-green color vision deficiency. Use colorblind-safe palettes (viridis, cividis, ColorBrewer) and redundantly encode with shape/label/position, not color alone.
  • Avoid the rainbow/jet colormap: it is perceptually non-uniform (false boundaries, misleading luminance). Prefer perceptually uniform maps (viridis, magma, cividis).
  • Gestalt principles (proximity, similarity, enclosure, connection) drive grouping - use small multiples (faceting) with shared axes instead of one overcrowded plot.
  • Lie Factor (Tufte) = (effect shown in graphic) / (effect in data); aim for ~1. Truncated axes, bubbles scaled by radius instead of area, and inconsistent scales inflate it.
  • Label directly rather than relying on legends when feasible, to reduce eye round-trips. Sort categorical axes by value, not alphabetically, unless an inherent order exists.

The Modern Tooling Stack (2026)

  • Python statics: Matplotlib (low-level, full control), Seaborn (statistical defaults + the seaborn.objects grammar-of-graphics interface), pandas .plot for quick EDA.
  • Grammar of Graphics: ggplot2 (R) and plotnine/Altair (Python) build plots declaratively from data + mappings (aesthetics) + geoms + scales + facets - composable and consistent.
  • Interactive/web: Plotly (+Dash), Altair/Vega-Lite (declarative JSON spec), Bokeh; JS: D3.js (max flexibility), Observable Plot, ECharts, Vega-Lite.
  • Dashboards/apps: Streamlit and Gradio for fast Python apps, Dash for production, Apache Superset / Metabase / Looker / Power BI / Tableau for BI; Evidence/Quarto for code-driven reports.
  • Big data: datashader / hvPlot rasterize millions of points to avoid overplotting; WebGL backends (Plotly scattergl, deck.gl) for large interactive scenes.
  • Notebooks vs dashboards vs reports: choose by audience - exploratory (notebook), monitored/recurring (dashboard), one-shot narrative (report/slides). Match interactivity to need; static is often clearer for a fixed message.

Statistical & EDA Visualizations

  • Distribution: histogram (binning sensitive - try Freedman-Diaconis bin width), KDE (bandwidth sensitive), box plot (median/IQR/whiskers/outliers), violin (KDE + box), ECDF (no binning bias, ideal for comparing distributions/quantiles).
  • Relationships: scatter (+ regression/LOWESS line), pair plot for multivariate overview, 2D density/hexbin for overplotting, correlation heatmap (annotate, mask upper triangle, and remember it captures only linear, Pearson-style association).
  • Handle overplotting with transparency (alpha), jitter, hexbin/2D-hist, sampling, or datashader - dense scatter plots become solid blobs otherwise.
  • Show uncertainty: error bars, confidence/prediction bands, or bootstrap CIs (Seaborn shows a 95% bootstrap CI by default in lineplot/barplot). Always state whether bars are SD, SE, or CI.
  • Time series: plot raw + rolling mean, decompose into trend/seasonality/residual, use log scale for multiplicative growth, and use consistent time bins; calendar heatmaps reveal seasonality.
  • Log scale tip: use log when data spans orders of magnitude or growth is multiplicative; equal visual distances then represent equal ratios (a power law becomes a straight line).

ML-Specific Visualizations

  • Model evaluation: confusion matrix (normalized), ROC curve + AUC, precision-recall curve (preferred under class imbalance), calibration/reliability curve, lift/gain charts.
  • Diagnostics: residual plots (check homoscedasticity/patterns), Q-Q plot (normality), learning curves (bias vs variance), validation curves over a hyperparameter.
  • Interpretability: SHAP summary/beeswarm + dependence plots, permutation importance, partial dependence (PDP) and ICE curves; prefer SHAP or permutation importance over raw tree impurity feature_importances_ (biased toward high-cardinality / continuous features).
  • High-dimensional/embeddings: PCA (linear, variance-preserving), t-SNE and UMAP (nonlinear, neighborhood-preserving) - UMAP is usually faster and tends to retain more global structure; never read cluster sizes or inter-cluster distances from t-SNE as literal.
  • Surface data shift and class balance: feature distributions train vs prod, target distribution, and per-class metrics - a single accuracy number hides imbalance failures.
  • For experiments/training: track loss/metric curves over steps (W&B, TensorBoard, MLflow), plot per-class confusion, and compare runs with parallel-coordinate plots.

Storytelling, Dashboards & Communication

  • Lead with the insight: every chart needs a takeaway-style title ("Revenue fell 12% in Q3"), annotations on key points, and removal of everything that does not support the message.
  • Know your audience: executives want one annotated headline chart; analysts want interactivity/filters; engineers want monitoring dashboards with thresholds and alerts.
  • Dashboard layout: most important KPI top-left (F/Z reading pattern), consistent color semantics across panels, shared scales for comparable panels, and sensible defaults so the first view is already useful.
  • Performance & scale: pre-aggregate, paginate/sample, cache queries, and downsample time series; interactivity should not require loading millions of rows client-side.
  • Accessibility & integrity: colorblind-safe palettes, sufficient contrast, alt text/data tables, and honest axes/scales - good visualization does not mislead, even unintentionally.
  • Reproducibility: version the spec/code (Vega-Lite JSON, plotting scripts), parameterize, and keep the data-to-chart pipeline in code so visuals regenerate on data updates.