What Is Pygal? A Python Charting Library for SVG Charts
Updated
Pygal is a Python charting library for building charts programmatically with minimal code. You use it when you want to turn data into a chart inside a Python script or application, and you want the output to be a scalable SVG rather than a raster image. The library is documented at pygal.org and is maintained by Kozea as an open-source project.
What Pygal does
Pygal's stated purpose is "beautiful python charting" and "simple python charting." The core workflow is small: pick a chart type, feed it data, and render.
The documentation's own example shows the pattern:
pygal.Bar()(1, 3, 3, 7)(1, 6, 6, 4).render()
Read that in three steps:
pygal.Bar()creates a bar chart object.- Each call with values adds a data series — here two series,
(1, 3, 3, 7)and(1, 6, 6, 4). .render()produces the chart output.
The input is your numeric data; the action is choosing a chart type and adding series; the expected result is a rendered chart you can embed or save.
Why SVG matters
Pygal renders charts as SVG (Scalable Vector Graphics). That has practical consequences:
- Scalable — SVG is vector-based, so it stays sharp when resized, unlike a fixed-resolution PNG.
- Web-friendly — SVG is a standard browser format, so charts can be placed directly in web pages.
- Text-based — SVG is markup, so it can be styled, embedded, and manipulated like other web content.
If you need a raster image for print or a specific pipeline, that is a different requirement than what Pygal is built around.
When Pygal is a good fit
| Your situation | Pygal fits? |
|---|---|
| You want charts generated from Python with little code | Yes — the API is deliberately terse |
| You need scalable, web-embeddable output | Yes — SVG is the native output |
| You want an open-source library | Yes — it is a Kozea project |
| You need a chart type or output format not covered by the library | Check the API index in the docs first |
Where to go next
The pygal.org documentation is organized into these sections:
- Documentation — the main usage guide
- Installing — how to get Pygal set up
- Contributing — how to take part in the project
- Changelog — what changed between versions
- API Index and Module Index — reference material for specific classes and functions
The documentation shown is for Pygal 3.0.5. Start with the Documentation overview, then use the API Index when you need details on a specific chart type or method.