Skip to main content

A Python toolkit for producing publication-quality microeconomics diagrams.

Project description

Econ-Viz

PyPI Python License Tests Coverage

A Python toolkit for producing publication-quality microeconomics diagrams. Define utility functions declaratively, solve for consumer equilibria, and export figures as PNG, PDF, SVG, or pure TikZ — all in a few lines of code.

Installation

pip install econ-viz

Requires Python 3.12 or later.

Quick Start

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, x_label="x", y_label="y",
             title="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")

TikZ export writes a standalone LaTeX document with only TikZ drawing commands:

cvs.save("cobb_douglas.tex", tikz_scale=0.0125)

The default TikZ scale maps a 6 inch wide Matplotlib figure to about 7.5 cm.

Cobb-Douglas indifference map with budget line and equilibrium point

Notebook

The project ships with an interactive playground notebook:

notebook/econ-viz Playground.ipynb

Download it and open it in Jupyter, VS Code, or Colab. The first code cell upgrades econ-viz from PyPI for fresh runtimes.

Highlights

  • Built-in models: Cobb-Douglas, Leontief, Perfect Substitutes, CES, Satiation, Quasi-Linear, Stone-Geary, and Translog
  • Solver support for interior, kink, boundary, and corner solutions
  • Closed-form demand helpers with solution_tex(...)
  • Comparative tools including comparative_statics(...) and slutsky_matrix(...)
  • Multi-panel Figure layouts, PricePath / IncomePath, and linked DemandDiagram
  • CLI support for plotting and closed-form demand output
  • Color-blind-friendly default palette (themes.COLORBLIND_CYCLE_RGB) sourced from thriveth/8560036, with related citation at DOI:10.1080/00220485.1996.10844911

Additional Tools

Closed-form Marshallian demand in TeX:

from econ_viz import solution_tex
from econ_viz.models import CobbDouglas

tex = solution_tex(CobbDouglas(alpha=0.4, beta=0.6))

Slutsky matrix:

from econ_viz import slutsky_matrix
from econ_viz.models import CobbDouglas

S = slutsky_matrix(CobbDouglas(alpha=0.4, beta=0.6), px=2.0, py=3.0, income=60.0)
# S.s_xx, S.s_xy, S.s_yx, S.s_yy

CLI

econ-viz help
econ-viz models
econ-viz solve-tex --model cobb-douglas --symbolic-params

Plotting example:

econ-viz plot --model cobb-douglas --alpha 0.5 --beta 0.5 \
              --px 2 --py 3 --income 30 \
              --fill --show-ray \
              --output cobb_douglas.png

Documentation

Full documentation lives at econ-viz.org.

License

MIT © Anthony Sung

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

econ_viz-1.6.0.tar.gz (68.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

econ_viz-1.6.0-py3-none-any.whl (94.1 kB view details)

Uploaded Python 3

File details

Details for the file econ_viz-1.6.0.tar.gz.

File metadata

  • Download URL: econ_viz-1.6.0.tar.gz
  • Upload date:
  • Size: 68.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for econ_viz-1.6.0.tar.gz
Algorithm Hash digest
SHA256 4620e442dae08027f418bdf1a81faf6f733d5dd7fbc019f690504d9b8581acf8
MD5 1652627e6c71e321a7b1b505547b659d
BLAKE2b-256 520fdcf5d2d40561c854ce1bf92e3ddf7e079365fa7e87a8982eef3174a5962f

See more details on using hashes here.

Provenance

The following attestation bundles were made for econ_viz-1.6.0.tar.gz:

Publisher: publish.yml on EconViz/econ-viz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file econ_viz-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: econ_viz-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 94.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for econ_viz-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8991617ad22d03afba7e168cfbdc2c076774bc9ecd84f310b78ce34ff5a73aeb
MD5 7df327b26961a3552a0a859b89f718aa
BLAKE2b-256 e9cbf8d85c3dad15ac528af5074394ffdf7a555215f01308fec40ebcbdf2d091

See more details on using hashes here.

Provenance

The following attestation bundles were made for econ_viz-1.6.0-py3-none-any.whl:

Publisher: publish.yml on EconViz/econ-viz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page