Pygal

3.1.0 · active · verified Mon Apr 13

Pygal is an open-source Python library for creating dynamic and interactive SVG (Scalar Vector Graphics) charts. It is known for its ease of use, allowing developers to generate high-quality, scalable visualizations with minimal code. Pygal is currently at version 3.1.0 and maintains an active development and release cadence, with recent updates focusing on fixes and minor enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a simple bar chart with two data series and render it to an SVG file. It also shows the (commented out) option to render directly in a web browser, which requires the `lxml` optional dependency.

import pygal

# Create a Bar chart object
bar_chart = pygal.Bar()

# Add data series
bar_chart.add('Fibonacci', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34])
bar_chart.add('Prime', [2, 3, 5, 7, 11, 13, 17, 19, 23, 29])

# Render the chart to an SVG file
bar_chart.render_to_file('bar_chart.svg')

# To display in a browser (requires lxml installed)
# bar_chart.render_in_browser()

print("Chart rendered to bar_chart.svg")

view raw JSON →