Metadata-Version: 2.5
Name: econographs
Version: 0.1.0
Summary: Publication-quality microeconomics and macroeconomics diagrams.
Author: Econographs Contributors
License-Expression: MIT
License-File: LICENSE
Keywords: diagrams,economics,graphs,macroeconomics,matplotlib,microeconomics
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: matplotlib>=3.7
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Provides-Extra: dev
Requires-Dist: mkdocs-material>=9.5; extra == 'dev'
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pytest-mpl>=0.16; extra == 'dev'
Requires-Dist: pytest>=7.4; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# econographs

Publication-quality **microeconomics** and **macroeconomics** diagrams in Python.

`econographs` is a matplotlib library for textbook-style figures: origin at zero, curves labeled on the line, dashed drop-lines at equilibria, shaded surplus and deadweight-loss regions, and arrows for shifts. Every chart returns a matplotlib `(figure, axes)` pair so you can keep customizing.

## Install

```bash
pip install -e .
```

With documentation and test tools:

```bash
pip install -e ".[dev]"
```

Requires Python 3.10+.

## Quick start

```python
from econographs import Linear, SupplyDemand, theme

theme.use("textbook")  # also: "journal", "teaching"

fig, ax = (
    SupplyDemand()
    .demand(Linear(10, -1), label="D")
    .supply(Linear(2, 0.5), label="S")
    .equilibrium()
    .surplus(consumer=True, producer=True)
    .plot()
)
fig.savefig("market.pdf")
```

![Supply and demand](docs/assets/supply_demand.png)

A tax with incidence and deadweight loss:

```python
fig, ax = (
    SupplyDemand()
    .demand(Linear(10, -1), label="D")
    .supply(Linear(2, 0.5), label="S")
    .tax(2.0, show_incidence=True, show_dwl=True)
    .plot()
)
```

Notebook one-liners wrap the same classes:

```python
from econographs import Linear, supply_demand

fig, ax = supply_demand(Linear(10, -1), Linear(2, 0.5), surplus=True)
```

## Themes

| Name | Use |
| --- | --- |
| `textbook` | Near-black curves, serif labels, axis arrows (default) |
| `journal` | Tighter serif figure, grayscale fills, ticks on |
| `teaching` | Color-coded demand/supply, sans-serif |

Pass `theme="teaching"` into any chart, or `theme.use("journal")` for the process default. Override individual colors with `Theme.replace(...)`.

## Catalog

**Foundations:** PPF, comparative advantage, circular flow.

**Micro — markets:** supply and demand (shifts, surplus), tax incidence, subsidy, price ceiling/floor, elasticity comparison, tariff/quota.

**Micro — consumer:** budget constraint, indifference map, optimal choice, Hicksian income/substitution, Engel curve.

**Micro — producer and structure:** production function, isoquant/isocost, short-run cost family, LRAC, perfect competition (firm + market), monopoly, monopolistic competition, Cournot, kinked demand, third-degree price discrimination.

**Micro — failure and distribution:** externality (Pigou), public goods, labor market, Lorenz/Gini, Edgeworth box.

**Macro — short run:** AD-AS, Keynesian cross, consumption function, IS-LM (liquidity trap), Mundell-Fleming, Phillips curve, money market, loanable funds, crowding out.

**Macro — growth and open economy:** Solow, aggregate production, forex, business cycle, Laffer curve, yield curve.

See the [docs gallery](docs/gallery/micro.md) for copy-paste examples of every chart.

## Design

Curves are inverse functions where textbooks expect it (`P = a + bQ`). Geometry (intersections, surplus areas) is solved in closed form for linear curves and numerically otherwise. Charts compose those primitives; they do not hide matplotlib.

## Development

```bash
pip install -e ".[dev]"
pytest
pytest --mpl                 # visual regression against tests/baseline
ruff check src tests
mypy
python scripts/generate_gallery.py
```

## License

MIT
