Home
A Python toolkit for producing publication-quality microeconomics diagrams.
Documentation: https://econ-viz.org
Source Code: https://github.com/EconViz/econ-viz
from econ_viz import Canvas, levels, solve
from econ_viz.models import CobbDouglas
model = CobbDouglas(alpha=0.5, beta=0.5)
eq = solve(model, px=2.0, py=3.0, income=30.0)
lvls = levels.around(eq.utility, n=5)
cvs = Canvas(x_max=20, y_max=15, title=r"Cobb-Douglas $x^{0.5} y^{0.5}$")
cvs.add_utility(model, levels=lvls)
cvs.add_budget(2.0, 3.0, 30.0, fill=True)
cvs.add_equilibrium(eq, show_ray=True)
cvs.save("cobb_douglas.png")
Features
-
Eight built-in utility models
Cobb-Douglas, Leontief, Perfect Substitutes, CES, Translog, Satiation, Quasi-Linear, and Stone-Geary — covering the full range of standard microeconomic preferences.
-
Automatic equilibrium solving
Interior solutions, kinked optima (Leontief), and corner solutions — all handled via SLSQP with no manual setup required.
-
Multi-panel teaching figures
Build side-by-side, stacked, and grid layouts with
Figure, then combine budget lines, indifference curves, and equilibria across panels. -
Demand-path diagrams
Generate
PricePath,IncomePath, and linkedDemandDiagramviews for PCC, ICC, and Marshallian-demand teaching graphics. -
LaTeX parser
Pass a LaTeX expression like
x^{0.4} y^{0.6}directly and get back a fully-configured model instance. -
Publication-ready export
Save as PNG, PDF, or SVG for presentations, papers, and the web.
-
Animated GIF sweeps
Render parameter, price, and income animations with
Animator, including budget-only teaching sweeps for notebook demos and web docs. -
Notebook widgets
Use
WidgetViewerin Jupyter with a slider plus numeric input for each parameter, so students can drag or type exact values. -
Analysis helpers
Compute comparative statics, Slutsky matrices, and inspect homogeneity, Euler's theorem, homotheticity, and demand degree-0 behaviour.
-
Advanced models
Wrap any callable as a utility function, or extend to N goods with 2-D projection via
MultiGoodCD.freeze(). -
CLI
Generate diagrams from the terminal and print closed-form Marshallian demand formulas with
solve-tex.
Install
Requires Python 3.10 or later.