Skip to content

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:

cvs = Canvas(x_max=20, y_max=15, dpi=150)   # lower DPI for faster preview

DPI is clamped to the range 1–1200.

TikZ / PGFPlots (LaTeX)

Save with a .tex extension to export TikZ source:

cvs.save("figure.tex")

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:

cvs.show()

In the CLI, omit --output to get the same behaviour:

econ-viz plot --model cobb-douglas --px 2 --py 3 --income 30