Export
Raster formats
Call cvs.save() with a .png, .pdf, or .svg extension:
cvs.save("figure.png") # PNG at the canvas DPI (default 300)
cvs.save("figure.pdf") # PDF (vector, DPI ignored)
cvs.save("figure.svg") # SVG (vector, DPI ignored)
The dpi parameter on Canvas controls raster resolution:
DPI is clamped to the range 1–1200.
TikZ / PGFPlots (LaTeX)
Save with a .tex extension to export TikZ source:
Include the file in a LaTeX document:
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{figure}
\input{figure.tex}
\caption{Cobb-Douglas indifference map}
\end{figure}
Interactive window
Call cvs.show() to open a live matplotlib window instead of saving:
In the CLI, omit --output to get the same behaviour: