Skip to content

Econ-Viz: Python library for microeconomics diagrams

Econ-Viz

A Python toolkit for producing publication-quality microeconomics diagrams.

Publish Coverage PyPI Python


Source Code: https://github.com/EconViz/econ-viz

PDF Manual: English, 繁體中文, 简体中文

Contact: contact@econ-viz.org


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, CES, and other textbook utility functions, from perfect substitutes to satiation, ready to plot.

    Model catalogue

  • Automatic equilibrium solving

    Give prices and income and get the consumer's optimal bundle. Interior, kinked, and corner solutions need no manual setup.

    Quick Start

  • Multi-panel teaching figures

    Place diagrams side by side, stacked, or in a grid for before-and-after comparisons, decompositions, or lecture slides.

    Figures & demand diagrams

  • Demand-path diagrams

    Sweep a price or income to trace price- and income-consumption curves, linked to the Marshallian demand curve below.

    Figures & demand diagrams

  • LaTeX parser

    Paste a utility function written in LaTeX and get a ready-to-plot model with its functional form and parameters detected.

    LaTeX parsing

  • Publication-ready export

    Save to PNG, PDF, or SVG in one line. Vector output stays sharp at any size for papers, slides, and the web.

    Export formats

  • Animated GIF sweeps

    Turn parameter, price, or income changes into GIFs so students can watch the equilibrium move with the budget line.

    Animation

  • Notebook widgets

    Tune parameters in Jupyter with sliders or typed values and watch the diagram update as students explore on their own.

    Interactive widgets

  • Analysis helpers

    Compute comparative statics and Slutsky matrices, and check the homogeneity and homotheticity behind every diagram.

    Analysis tools

  • Advanced models

    Wrap any function as a utility model, or project many-good preferences onto a plane to go beyond the textbook cases.

    Advanced models

  • CLI

    Generate diagrams from the terminal without writing Python, and print closed-form Marshallian demand ready for LaTeX.

    CLI reference

Install

uv add econ-viz

Requires Python 3.10 or later.

Comments