A home for “Code, debug, reuse this chart” workshop docs. The code is available on GitHub.

Code, debug, reuse this chart

What is Matplotlib?#

Matplotlib is a huge plotting library. In March 2024, the project has 256024 lines of code.

~/d/matplotlib ❯❯❯ find . -name "*.py" -exec cat {} + | wc -l
256024

With approximately 1114 classes.

~/d/matplotlib ❯❯❯ find . -name "*.py" -exec grep -h '^\s*class\s\+' {} + | wc -l
1114

It’s a big and very flexible codebase for creating any plots. And with great power comes a bigger challenge: understanding how to use it effectively. But before we dive into the code, let’s ask ourselves a question:

Why do we need a workshop about matplotlib in the era of Large Language Models and ChatGPT?#

In the keynote titled “Training the most important model” at PyConTH 2023, Naomi Ceder made a point that our mental models of how code and applications work are vital to understanding the capabilities of our tools and fixing their problems when things go wrong.

At the “Code, debug, reuse this chart” workshop, Artem and Teresa will help you build the mental model of matplotlib. This workshop aims to provide insights and skills that LLMs cannot offer, such as understanding how to utilize matplotlib and organize Python visualization projects for re-usability.

After several attempts on making use of LLM for creating code for this tutorial, with an opinionated view, we could say that ChatGPT is very good in extrapolating words for matplotlib code generation. This often leads to a “spaghetti code.” The task of condensing the generated content by summarizing and optimizing was almost always failed causing the divergent results and change in the visual output. This makes us believe that there are still numerous opportunities for chart craftsmanship, and this tutorial should help you to get the necessary skills.

Setup#

Check out the Setup section for further information, including how to install the project.

Contents#

About the Authors#

Artem Kislovskiy is a professional software engineer who is playing with computers for fun and profit. With a background in computational physics, Artem’s journey into programming and data visualisation began during his academic pursuits. Having previously contributed to projects at EPFL, he remains actively engaged with the research community. Artem is a vice chair of EuroPython Society and a one of the organisers of EuroPython and EuroSciPy conferences. He resides in Lausanne with his wife and their beloved canine companion.

Teresa Kubacka is a data scientist and software engineer with a background in physics and a passion for data visualization. She originally contacted Artem with an idea to create a workshop about matplotlib.