5.4.19 · D3 · HinglishScientific Computing (Python)

Worked examplesPublication-quality figures — LaTeX labels, colormaps, DPI

3,900 words18 min read↑ Read in English

5.4.19 · D3 · Coding › Scientific Computing (Python) › Publication-quality figures — LaTeX labels, colormaps, DPI

Yeh page parent recipe ko tab tak drill karta hai jab tak koi bhi scenario surprise na kar sake. Hum har knob ko — Dots, Letters, Colors — aur unke andar chhupe har edge case ko ek-ek karke cover karte hain.

Is poore page mein, DPI ka matlab hai dots per inch (DPI) — final printed figure ke ek inch mein kitne pixels packed hain. Hum ise matrix mein use karne se pehle neeche define aur re-derive karte hain.


The scenario matrix

Har figure problem in cells mein se kisi ek mein aati hai. Neeche ke examples mein us cell ka tag lagaya gaya hai jis mein woh fit hoti hai. Kul nine cells (A1–A4, L1, C1–C3, W1, X1) hain aur nine examples (Ex 1–Ex 9) hain — ek per cell, koi gap nahi. (Yahaan DPI = dots per inch.)

Cell Knob Scenario kya hai Example
A1 Dots figsize + DPI diya → pixels nikalo Ex 1
A2 Dots pixels + DPI diya → inches nikalo (inverse) Ex 2
A3 Dots degenerate: DPI badhaya lekin figsize default par choda → font chhota ho gaya Ex 3
A4 Dots limiting: vector (PDF), DPI → "infinite" Ex 4
L1 Letters raw-string escape trap (\a, \n, \t) Ex 5
C1 Colors low→high data ke liye sequential map (koi centre nahi) Ex 6
C2 Colors centred case: data ka ek meaningful zero centre hai → diverging Ex 7
C3 Colors jet ka grayscale / colorblind failure Ex 8
W1 Mixed real-world word problem (double-column poster) Ex 9a
X1 Mixed exam twist: unit conversion cm → inches, physical font size Ex 9b

Hum number tools pehle banate hain, phir use karte hain. Yahan sab kuch ek multiplication ya uska inverse hai — dekho Dimensional analysis kyun units arithmetic guide karti hain.


The one formula, earned

Figure 1 (neeche). Ek single 1-inch bar (blue arrow) jisme evenly spaced yellow dots hain — yahi "dots per inch" dikhta hai. Char green boxes left-to-right stack hain jo inches of width dikhate hain; red arrow poore inches span karta hai. Un inches mein saare yellow dots count karo aur tumhe pixels milte hain — picture hi formula hai.

Figure — Publication-quality figures — LaTeX labels, colormaps, DPI
Figure 1: Per-inch dot count ko stack karna. Blue = ek inch aur uske dots; green = width ke inches; red = total width. Total dots across = = pixels.

Figure mein blue bar dekho: yeh 1 inch lamba hai aur dots hold karta hai. aise stack karo aur tumhare paas dots across ho jaate hain. Multiplication yahaan bas yahi hai — per-inch dot count ki repeated stacking.


Ex 1 — Cell A1: forward calculation


Ex 2 — Cell A2: formula ko backwards chalana


Ex 3 — Cell A3: degenerate "cranked DPI" mistake


Ex 4 — Cell A4: limiting case, vector output


Ex 5 — Cell L1: raw-string escape trap


Ex 6 — Cell C1: low→high data ke liye sequential map


Ex 7 — Cell C2: centred case → diverging map


Ex 8 — Cell C3: grayscale / colorblind test


Ex 9a — Cell W1: double-column poster (word problem)


Ex 9b — Cell X1: exam twist (cm → inch conversion)


Recall Har cell ek saanch mein

DPI×inches=pixels (A1); invert karne ke liye divide karo (A2); figsize ke bina DPI fonts shrink karta hai (A3); PDF = no DPI (A4); r missing hai toh backslashes kha jaata hai (L1); low→high bina centre ke ⇒ sequential viridis (C1); meaningful zero centre ⇒ diverging coolwarm (C2); jet grayscale mein mar jaata hai, viridis jeeta hai (C3); multiply karne se pehle cm→in convert karo (X1).


Self-check

Ex 1 pixel width 3.5 in ke liye 300 dpi par?
px.
Ex 2 physical width 1800 px ke liye 600 dpi par?
in (pixels ko DPI se divide karo).
Ex 3 apparent font size, 9 pt on 6.4-in canvas 3.5 in tak squeeze ki gayi?
pt (unreadable).
Ex 9b 8.9 cm column ke liye 300 dpi par pixels?
px — pehle cm→in convert karo ( in).
Kaun sa cell formula invert karne ke liye kehta hai?
A2 — pixels aur DPI diye hue hain, solve karo.
PDF ke liye DPI meaningless kyun hai?
Yeh pixels ka grid nahi, shapes store karta hai ( ka par koi upper bound nahi).
Sequential vs diverging: kya decide karta hai?
Kya data ka koi meaningful centre hai — koi nahi ⇒ sequential (C1), zero centre ⇒ diverging (C2).
Luminance kya hai?
Perceived brightness / grayscale value, ; honest ordering ke liye monotonically rise honi chahiye.

Connections

  • Publication-quality figures — LaTeX labels, colormaps, DPI (index 5.4.19)
  • Matplotlib basics — figure and axes objects
  • Colormaps and color theory in visualization
  • LaTeX typesetting
  • Raster vs vector graphics
  • Dimensional analysis
  • Reproducible research and rcParams

A1 A2

L1 raw string

C1 C2 C3

forward

inverse

centre in data

low to high

Scenario matrix

Dots cell

Letters cell

Colors cell

pixels = inches times DPI

inches = pixels over DPI

diverging coolwarm

sequential viridis