5.4.19 · D1Scientific Computing (Python)

Foundations — Publication-quality figures — LaTeX labels, colormaps, DPI

2,355 words11 min readBack to topic

Before we can turn any dial we must agree on what every word and symbol means. The parent note throws around figsize, dpi, points, pixels, viridis, r"...", $...$. A smart 12-year-old has seen none of these. So we build each one from nothing, in an order where every new idea leans only on the ones before it.


1. The inch — the ruler everything is measured against

The picture (Figure 1): a ruler drawn along the bottom shows the inch scale; the amber bar marks exactly one inch, and a small caption reminds you it equals 2.54 cm. Above it, a cyan rectangle is a 3.5-inch-wide figure sitting on that ruler, with a double-headed cyan arrow measuring its 3.5 in width. Nothing about computers yet — this is length you could measure with your hands.

Figure — Publication-quality figures — LaTeX labels, colormaps, DPI

Why the topic needs it: journals don't ask for "big" or "small" figures — they ask for an exact column width in inches (e.g. 3.5 in). Every other measurement in this topic (points, DPI) is defined relative to the inch. It is the anchor. Miss this and nothing else has meaning.


2. Pixels and dots — the smallest specks (and why they differ)

The picture (Figure 2): the left panel shows a smooth cyan sine curve made of many small pixels; the right panel shows the same curve rebuilt from only nine fat amber pixels (with the true curve ghosted in white behind it), so it looks blocky — like Minecraft. Same shape, far fewer specks per inch.

Figure — Publication-quality figures — LaTeX labels, colormaps, DPI

Why the topic needs it: "sharpness" means many small specks per inch; "blocky" means few big specks per inch. To talk about sharpness we first need the word for the speck — and to avoid the PPI/DPI trap above.


3. DPI — how tightly the specks are packed into an inch

Now we join idea 1 (the inch) and idea 2 (the pixel/dot).

Why "per inch" and not "total dots"? Because your eye reads the picture at its physical size on paper. A million dots spread over a wall looks blocky; the same million dots squeezed into a stamp looks razor-sharp. Only dots per inch captures how sharp it looks. That is exactly why the unit divides by inches — see Dimensional analysis.


4. figsize — the physical size of the canvas

The picture (Figure 3, left side): a wide cyan rectangle labelled "default 6.4 in canvas" versus a narrower amber rectangle labelled "3.5 in column", each with a double-headed arrow giving its width. The identical word "Intensity" is drawn on both — notice it looks smaller relative to the wider card. That relationship is the heart of the whole topic.

Why the topic needs it: the journal's column width is your figsize width. Set it first, always.


5. The point — the unit fonts are measured in

The picture (Figure 3, in full): the cyan 6.4-in canvas carries a large, legible "Intensity"; the amber 3.5-in canvas carries the same 9-pt label rendered tiny after the shrink-to-fit. The white caption underneath spells out the shrink factor .

Figure — Publication-quality figures — LaTeX labels, colormaps, DPI

Why set figsize before font size? Because the point is tied to the inch, so the inch canvas must be fixed first; only then does "9 pt" mean what you think on the printed page. This is the reasoning behind the parent's rule "figsize first, always."


6. Raster vs vector — two ways to store the drawing

Why the topic needs it: line plots (axes, curves, text) are shapes → save as vector PDF, infinitely sharp. Photos and dense heatmaps are already grids of color → save as raster PNG at high DPI. More in Raster vs vector graphics.


7. The string, the raw string, and $...$

Now to the text dial. Two symbols confuse everyone: the leading r and the dollar signs.

The picture (Figure 4): the code r"$\lambda$" is shown large. A cyan arrow points at the r with the note "keep the backslash (Python side)"; an amber arrow points at the $...$ with the note "turn on math mode (LaTeX side)"; below, the clean italic result appears. Two arrows, two separate jobs — both needed.

Figure — Publication-quality figures — LaTeX labels, colormaps, DPI

8. mathtext vs text.usetex

Why the choice matters: if your paper uses Computer Modern font, usetex makes the figure text blend in seamlessly; mathtext gets close but not identical.


9. Colormap and perceptual uniformity

Why the topic needs it: an honest figure must not invent features that aren't in the data. A monotonic (always-brightening) colormap keeps your eye truthful.


10. rcParams — one place to set every dial


Prerequisite map

How to read this map (Figure 5): arrows point from a prerequisite toward what it enables. The inch (amber, top) is the root everything grows from; follow the cyan arrows down and they all converge on the amber goal box "Publication-quality figure" at the bottom.

Figure — Publication-quality figures — LaTeX labels, colormaps, DPI

Inch physical length 2.54 cm

Pixel screen speck PPI

Dot printer speck DPI

DPI pixels per inch

figsize inches

Point 1 over 72 inch

Legible font size

Raster vs vector

String and raw r prefix

Math mode dollar signs

Colormap perceptual uniformity

rcParams global settings

Publication-quality figure

The map reads top-down to the goal: the inch feeds DPI, figsize and the point; the point plus figsize decide font legibility; strings feed math mode; and everything funnels into the publication-quality figure.


Equipment checklist

Cover the answers and test yourself — you are ready for the topic if you can state each.

What is an inch, exactly?
A fixed length equal to 2.54 cm — a precise, measurable distance, not a thumb-width guess.
What is a pixel, and how does it differ from a printer dot?
A pixel is the smallest colored square on a screen (counted as PPI); a dot is the smallest ink speck of a printer (counted as DPI) — a printer may use many dots per pixel.
Define DPI in words.
The number of pixels packed into one inch of the final figure — a density, not a total.
Give the formula for pixels across a figure.
width in inches times DPI, because the inch unit cancels leaving pixels.
What does figsize control — size or sharpness?
Physical size (inches); DPI controls sharpness.
How many inches is a point?
One point is 1/72 of an inch.
Why must figsize be set before font size?
Fonts are measured in points (inches), so the inch canvas must be fixed first or text scales with the figure and becomes illegible.
Raster vs vector — which for line plots?
Vector (PDF); it stores shapes, sharp at any zoom, DPI irrelevant.
What does the leading r in r"$\lambda$" do?
Makes a raw string so backslashes aren't eaten as escape codes and reach LaTeX intact.
What do $...$ switch on?
LaTeX math mode — italic symbols inside, plain text outside.
What makes a colormap perceptually uniform?
Equal data steps produce equal-looking brightness steps (monotonic), like viridis; jet fails this.
What is rcParams for?
A global settings dictionary so one update styles every figure, aiding reproducibility.

Connections

  • Parent topic
  • Matplotlib basics — figure and axes objects
  • Colormaps and color theory in visualization
  • LaTeX typesetting
  • Raster vs vector graphics
  • Dimensional analysis
  • Reproducible research and rcParams