Plot guides › How-to

Export a plot as SVG, PDF or 300 dpi PNG/TIFF

For print, save line art as a vector format (PDF, SVG or EPS), which scales without blurring. If a journal asks for raster images, export PNG or TIFF at 300 dpi or more at the final printed size.

Example export a plot as svg, pdf or 300 dpi png/tiff made with matplotlib
Rendered from the code below, with example data.

When to use it

Watch out: DPI only matters for raster formats, and only at the final size. Scaling a small 300 dpi image up afterwards lowers its effective resolution.

Ask for it in pltchat

Upload your file and type something like:

"export as SVG and as a 600 dpi TIFF"

pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.

The matplotlib code

Self-contained with example data; swap in pd.read_csv(...) or pd.read_excel(...) for your own file.

import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["pdf.fonttype"] = 42         # keep text editable in PDF
plt.rcParams["svg.fonttype"] = "none"     # keep text as text in SVG

rng = np.random.default_rng(36)
fig, ax = plt.subplots(figsize=(3.5, 2.6))     # final printed size, inches
ax.scatter(rng.normal(size=60), rng.normal(size=60), s=10)
ax.set_xlabel("x")
ax.set_ylabel("y")
fig.tight_layout()

fig.savefig("figure.pdf", bbox_inches="tight")              # vector
fig.savefig("figure.svg", bbox_inches="tight")              # vector
fig.savefig("figure.png", dpi=300, bbox_inches="tight")     # raster
fig.savefig("figure.tiff", dpi=600, bbox_inches="tight",
            pil_kwargs={"compression": "tiff_lzw"})
plt.show()

Make this with your data

Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.

Related plots