VISUALIZATION GUIDEMath for LLMs

VISUALIZATION GUIDE

Docs

Concept Lesson
Advanced
4 min

Learning Objective

Understand VISUALIZATION GUIDE well enough to explain it, recognize it in Math for LLMs, and apply it in a small task.

Why It Matters

VISUALIZATION GUIDE gives you the math vocabulary behind model behavior, optimization, and LLM reasoning.

VisualizationDocsMandatory Setup BlockColor PalettePrimary Colors Colorblind-Safe Wong 2011
Private notes
0/8000

Notes stay private to your browser until account sync is configured.

VISUALIZATION GUIDE
3 min read18 headings

Authority: Every plot produced in this repository must satisfy the rules in this document. Consistency across 25 chapters depends on strict adherence.


1. Mandatory Setup Block

Copy this verbatim into every notebook that produces plots.

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.


2. Color Palette

2.1 Primary Colors (colorblind-safe, Wong 2011)

RoleHexWhen to use
Primary#0077BBMain curve, first series
Secondary#EE7733Second curve, contrast
Tertiary#009988Third series
Error / negative#CC3311Errors, warnings, losses
Neutral#555555Annotations, reference lines
Highlight#EE3377Special points, emphasis
Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.

2.2 Colormaps by Purpose

PurposeColormapUsage
Heatmaps, attention"viridis"Attention weight matrices
Diverging (signed)"RdBu_r"Weight matrices, gradient sign
Probability / density"plasma"Loss landscapes
Categorical (≤ 10 classes)"tab10"Class labels

Forbidden colormaps: "jet", "rainbow", "hot" — they distort perception and fail colorblind users. Never encode binary information with red vs. green alone.


3. Required Plot Elements

Every figure must include all of the following:

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.

Checklist for every figure:

  • Title set with ax.set_title()
  • Both axes labelled with ax.set_xlabel() / ax.set_ylabel()
  • LaTeX math in labels: "$\\lambda_i$" (double backslash in Python strings)
  • Legend present when 2+ series
  • fig.tight_layout() called before plt.show()
  • All colors from COLORS dict or approved colormaps
  • No bare plt.plot() without assigning to ax

4. Plot Templates by Type

4.1 Line Plot (curves, training loss, convergence)

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.

4.2 Heatmap (matrices, attention, correlation)

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.

For seaborn:

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.

4.3 Scatter Plot (embeddings, data distributions)

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.

4.4 Bar Chart (comparison, ablation results)

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.

4.5 Multi-Panel Figure

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.


5. Mathematical Concept Conventions

5.1 Vector / Subspace Geometry

  • Draw vectors as arrows with ax.annotate("", xy=tip, xytext=origin, arrowprops=dict(arrowstyle="->", color=..., lw=2))
  • Show angles with matplotlib.patches.Arc
  • Label vectors with LaTeX: ax.text(x, y, r"$\mathbf{v}_1$", fontsize=13)
  • Use ax.set_aspect("equal") for any geometric figure — distorted axes are errors

5.2 Loss Landscapes

  • Use ax.contourf() for filled contours with cmap="plasma", levels=40
  • Overlay gradient descent path with ax.plot() in COLORS["error"]
  • Mark critical points (minima, saddles) with ax.scatter(), marker="*", s=200

5.3 Probability Distributions

  • PDF curves: filled with ax.fill_between(..., alpha=0.15) + solid line
  • Histograms: ax.hist(..., density=True, bins=40, alpha=0.7) with overlaid PDF
  • Always label x-axis as the random variable: "$x$", "$z$", etc.

5.4 Training Dynamics

  • Use log-scale y-axis for loss: ax.set_yscale("log")
  • Mark key events (warmup end, LR drop) with vertical dashed lines: ax.axvline(step, linestyle="--", color=COLORS["neutral"], label="LR drop")

6. Text and Annotations

Try itPython / Pyodide

Python snippet

Output
Run the code to see stdout, return values, and errors here.

Runs in your browser sandbox. DeepML does not send this code to the server.


7. What Not to Do

ViolationCorrect approach
plt.plot(x, y) without axAlways use fig, ax = plt.subplots()
No axis labelsEvery axis needs a label, always
No titleEvery figure needs a title
Default C0, C1 colorsUse COLORS dict
cmap="jet"Use "viridis" or "RdBu_r"
plt.show() before tight_layoutCall fig.tight_layout() first
Aspect ratio distortion in geometryax.set_aspect("equal") for geometric plots
Font size below 11Set fontsize ≥ 11 for all text
Legend outside figure boundsUse ax.legend(loc="best") or bbox_to_anchor with bbox_inches="tight"

Visualization conventions follow the scientific visualization standards of Rougier, Droettboom & Bourne (2014) "Ten Simple Rules for Better Figures" and the colorblind palette of Wong (2011) Nature Methods.

Skill Check

Test this lesson

Answer 4 quick questions to lock in the lesson and feed your adaptive practice queue.

--
Score
0/4
Answered
Not attempted
Status
1

Which module does this lesson belong to?

2

Which section is covered in this lesson content?

3

Which term is most central to this lesson?

4

What is the best way to use this lesson for real learning?

Your answers save locally first, then sync when account storage is available.
Practice queue