Free JYnapse Knowledge Base · Cheat Sheet

Data Visualization Cheat Sheet

Pick the right chart for the question, then build it. Design principles first; then matplotlib & seaborn recipes in Python.

For Analysts · report-makers · dashboard builders Level Beginner → Intermediate Languages EN · BM · 中文 on request

1 Which chart? Start here

CompareBar chart
Over timeLine chart
Part of a wholeStacked bar (not pie)
RelationshipScatter plot
DistributionHistogram / box plot
RankingSorted horizontal bar
Two dimensionsHeatmap
Single numberBig number + label

Choose the chart from the question, never the other way around.

2 Seven rules that fix 90%

  • Start bar-chart axes at zero. Not doing so lies about size.
  • Sort bars by value, not alphabetically.
  • Label directly — put numbers on bars, kill the legend where you can.
  • One idea per chart. If it needs a paragraph to explain, split it.
  • Grey the context, colour the point you want seen.
  • Drop the chartjunk — 3-D, heavy gridlines, borders, shadows.
  • Title = the takeaway ("Sales fell 12% in Q3"), not "Sales".

3 matplotlib — the base

import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(8, 4.5))
ax.bar(df.month, df.sales, color="#0F3D3E")
ax.set_title("Sales fell 12% in Q3")
ax.set_ylabel("RM")
ax.spines[["top","right"]].set_visible(False)
fig.tight_layout()
fig.savefig("sales.png", dpi=150)

Always use the object API (fig, ax) — predictable and scriptable.

4 The core plots

ax.plot(x, y)                # line
ax.bar(cats, vals)           # vertical bars
ax.barh(cats, vals)          # horizontal (ranking)
ax.scatter(x, y, s=sizes)    # scatter / bubble
ax.hist(values, bins=30)     # distribution
ax.fill_between(x, lo, hi)   # band

5 seaborn — fast & pretty

import seaborn as sns
sns.set_theme(style="whitegrid")

sns.barplot(data=df, x="month", y="sales")
sns.lineplot(data=df, x="date", y="v", hue="region")
sns.scatterplot(data=df, x="ad", y="sales")
sns.histplot(df.price, bins=30, kde=True)
sns.boxplot(data=df, x="region", y="price")
sns.heatmap(corr, annot=True, cmap="Greens")

seaborn understands DataFrames directly — one line per chart, sensible defaults, group with hue=.

6 Interactive — Plotly

import plotly.express as px

fig = px.line(df, x="date", y="sales",
              color="region", title="Sales by region")
fig.show()
fig.write_html("chart.html")   # embed anywhere

Use when viewers need to hover, zoom or toggle series — dashboards and web reports.

7 Colour, used well

  • Categories → distinct hues (max ~6, else group the tail into "Other").
  • Numbers low→high → one sequential ramp (light→dark).
  • Diverging (loss↔gain) → two hues around a neutral middle.
  • ~8% of men have colour-vision deficiency — avoid red/green pairs; test in greyscale.
  • Colour should encode something. Decoration-only colour adds noise.

8 Avoid these

Pie > 3 slicesUse a sorted bar
Dual Y-axesMisleads; use two charts
3-D anythingDistorts values
Truncated bar axisExaggerates gaps
Rainbow heatmapsNot perceptually even
Too many seriesSpaghetti — highlight one

9 Export clean

fig.savefig("out.png", dpi=150,
            bbox_inches="tight")
fig.savefig("out.svg")   # crisp for print/web
  • PNG at 150–300 dpi for slides & docs.
  • SVG for anything that will be resized or printed.
  • Set figsize up front so text stays legible after scaling.

10 The 30-second check

  • Can a stranger get the message in 5 seconds?
  • Does the title state the finding?
  • Are axes labelled with units?
  • Is anything redundant — remove it.
  • Would it survive being printed in black & white?

If you must explain the chart out loud, the chart isn't finished.