Charted: Zero-Dependency SVG Charting for Python

Charted Logo

PyPI GitHub Stars Downloads License

Create beautiful, publication-quality SVG charts with zero runtime dependencies.

pip install charted

Why Charted?

🚀 Zero Dependencies

Pure Python stdlib. No numpy, pandas, matplotlib, or seaborn required. Charts render as clean SVG strings.

🎨 Beautiful Output

Publication-quality SVG with proper typography, color contrast, and responsive design built-in.

📊 14 Chart Types

Bar, Column, Line, Scatter, Pie, Radar, Area, Bubble, Combo, HeatmapChart, Gantt, Histogram, Polar Area, Box Plot.

🎯 Simple API

Create a chart in 3 lines:

from charted import BarChart
chart = BarChart(data=[120, 180, 210], labels=["Q1", "Q2", "Q3"])
chart.save("sales.svg")
🌙 Theming System

Built-in light/dark/high-contrast themes plus full custom theme support.

📱 Jupyter Ready

Charts render inline automatically. No extra configuration needed.

Quick Start

from charted import BarChart, ColumnChart, LineChart

# Bar chart
bar = BarChart(
    data=[120, 180, 210, 150],
    labels=["Q1", "Q2", "Q3", "Q4"],
    title="Sales by Quarter"
)
bar.save("bar.svg")

# Column chart
column = ColumnChart(
    data=[120, 180, 210, 150],
    labels=["Q1", "Q2", "Q3", "Q4"],
    title="Sales by Quarter"
)
column.save("column.svg")

# Line chart
line = LineChart(
    data=[120, 180, 210, 150],
    labels=["Q1", "Q2", "Q3", "Q4"],
    title="Sales Trend"
)
line.save("line.svg")
# Create a bar chart from CSV
python -m charted create bar sales.svg --data sales.csv

# Batch process multiple files
python -m charted batch ./data ./output

# See all options
python -m charted --help
from charted import BarChart

# Just create a chart: it renders inline
BarChart(
    data=[120, 180, 210, 150],
    labels=["Q1", "Q2", "Q3", "Q4"],
    title="Sales by Quarter"
)

Chart Types

Vertical bars for time series and categorical comparisons.

Column Chart Example

Horizontal bars for long category labels.

Bar Chart Example

Line graphs for trends over time with XY mode support.

Line Chart Example

Scatter plots for correlations and distributions.

Scatter Chart Example

Pie and doughnut charts for proportional data.

Pie Chart Example

Multi-axis radar charts for comparison analysis.

Radar Chart Example

Heat maps for correlation matrices and density plots.

Heatmap Example

Gantt charts for project timelines with dependencies.

Gantt Chart Example

Area charts with fill support for cumulative data.

Area Chart Example

Bubble charts for 3-dimensional data visualization.

Bubble Chart Example

Combo charts mixing bars and lines in one view.

Combo Chart Example

Histograms for distribution analysis with auto-binning.

Histogram Example

Polar area charts for radial distribution data.

Polar Area Chart Example

Box plots for statistical quartile and outlier visualization.

Box Plot Example

Features

Multi-Series Support

Stacked, side-by-side, or grouped layouts for comparing multiple data series.

from charted import ColumnChart

data = [
    [120, 180, 210, 150],  # 2023
    [130, 190, 220, 160],  # 2024
]

chart = ColumnChart(
    data=data,
    labels=["Q1", "Q2", "Q3", "Q4"],
    series_names=["2023", "2024"],
    title="Sales Comparison"
)
chart.save("multi.svg")

Negative Values Handled

Proper zero baseline calculations for data with negative values.

from charted import ColumnChart

chart = ColumnChart(
    data=[120, -80, 210, -150],
    labels=["Q1", "Q2", "Q3", "Q4"],
    title="Profit/Loss"
)
chart.save("negative.svg")

Theming

Built-in themes plus full custom theme support.

from charted import BarChart

# Use built-in theme
chart = BarChart(
    data=[120, 180, 210],
    labels=["Q1", "Q2", "Q3"],
    theme="dark"  # or "light", "high-contrast"
)

# Or custom theme
chart = BarChart(
    data=[120, 180, 210],
    labels=["Q1", "Q2", "Q3"],
    theme={
        "colors": ["#FF6B6B", "#4ECDC4", "#45B7D1"],
        "background_color": "#1a1a2e",
        "grid_color": "#ffffff20"
    }
)

Data Loading

Load CSV/JSON without pandas.

from charted import load_csv, BarChart

x, y, labels = load_csv("sales.csv", x_col="Quarter", y_col="Revenue")
chart = BarChart(data=y, labels=x, title=labels[0])
chart.save("sales.svg")

Markdown Export

Generate embed-ready markdown for documentation.

from charted import BarChart

chart = BarChart(data=[120, 180, 210], labels=["Q1", "Q2", "Q3"], title="Sales")
chart.save("docs/sales.svg")
md = chart.to_markdown(path="docs/sales.svg")
# Output: ![Sales](docs/sales.svg)

Documentation

Chart Types

License

MIT License: See LICENSE for details.

Community

Built with ❤️ by Andryo Marzuki