DEV Community

Anthony Sung
Anthony Sung

Posted on

Stop Fighting Matplotlib for Economics Charts: econ-viz Is Your Friend

If you’ve ever tried to draw a simple microeconomics graph—say, an indifference curve tangent to a budget constraint—using raw Python or LaTeX, you know the struggle. You spend hours tweaking axis limits, hiding grids, calculating exact tangency points, and trying to align multiple subplots.

I got tired of doing this manually for my teaching materials, so I built econ-viz.

With our latest major update, it goes from being "a cool wrapper" to a "production-ready tool for economics lectures and papers." Here is how it solves the biggest headaches in drawing economics charts:

Elegant Multi-Panel Layouts

I’ve introduced a new Figure class that handles standard economic layouts out-of-the-box. Whether you need side-by-side, stacked, or 2x2 comparisons, you can generate them cleanly without fighting matplotlib.gridspec.

The DemandDiagram

Showing the derivation of the Marshallian demand curve requires stacking the utility space directly above the price-quantity space. econ-viz now perfectly aligns the axes and automatically links the tangency points on the indifference curves to the points on the demand curve below.

Analytical Tools

It doesn't just draw; it solves. I've added new features to support your analysis:

  • solution_tex: Outputs the optimal solutions in clean LaTeX format.
  • comparative_statics: Easily perform and visualize comparative statics.
  • slutsky_matrix: Computes the Slutsky matrix for deeper demand analysis.

The Mission

My goal with this open-source project is simple: Economists, educators, and students should spend their time analyzing models, not hand-coding chart coordinates.

If you are teaching microeconomics, writing notes, or publishing papers, give it a try!

📖 Documentation: econ-viz.org
🐙 GitHub Repo: github.com/EconViz/econ-viz

If you have a specific economics chart that is currently a nightmare to draw, drop a comment below or open an issue on GitHub! Happy plotting!

Top comments (0)