Skip to main content
Albero Academy

Figure Size & DPI

Control physical size and resolution for screen and print.

Figures & Layout6 min

A figure has a physical size (in inches) and a resolution (dots per inch). Together they set the pixel dimensions and how text and lines scale — crucial for matching a chart to its destination.

Size and DPI

figsize × dpi
fig, ax = plt.subplots(figsize=(8, 5), dpi=100)
# → 800 × 500 pixels on screen
fig.savefig("chart.png", dpi=300) # → 2400 × 1500 px for print

Key takeaways

  1. 01figsize=(w, h) sets the physical size in inches; dpi sets dots per inch.
  2. 02Pixel dimensions = figsize × dpi.
  3. 03Pick figsize for the aspect ratio and space; raise dpi (e.g. 300) at save time for print.
  4. 04Bigger figsize makes text relatively smaller; higher dpi just adds pixels.

Finished this chapter?

Mark it complete to track your progress through Matplotlib.