Skip to main content

CLI tool for creating charts

Project description

Chartroom

PyPI Changelog Tests License

CLI tool for creating charts from CSV, TSV, JSON, JSONL, or SQLite data using matplotlib. Designed to work well with Showboat.

Installation

pip install chartroom

Or:

uv tool install chartroom

Or run it directly with:

uvx chartroom

Demo

See the live demo document for examples of every chart type, input format, and style option with inline images. The demo was built using Showboat.

Usage

chartroom --help

Chart types

  • chartroom bar - Bar chart (vertical, supports grouped bars)
  • chartroom line - Line chart (supports multiple series)
  • chartroom scatter - Scatter plot
  • chartroom pie - Pie chart
  • chartroom histogram - Histogram

Data input

Provide data as a file, via stdin, or from a SQLite query:

# From a CSV file (auto-detected)
chartroom bar data.csv

# Explicit format
chartroom bar --csv data.csv
chartroom bar --tsv data.tsv
chartroom bar --json data.json
chartroom bar --jsonl data.jsonl

# From stdin
cat data.csv | chartroom bar --csv

# From SQLite
chartroom bar --sql mydb.sqlite "SELECT name, count FROM items"

Column selection

Columns are auto-detected from common names (name/label/x for x-axis, value/count/y for y-axis), or specify explicitly:

chartroom bar --csv -x region -y revenue data.csv

Multiple y columns create grouped/overlaid series:

chartroom bar --csv -x region -y q1 -y q2 -y q3 data.csv

Output

By default, saves to chart.png (incrementing to chart-2.png etc. to avoid overwrites). Use -o to specify a path:

chartroom bar --csv data.csv -o sales.png

The full absolute path of the output file is printed to stdout.

Output format

Use -f / --output-format to control what is printed to stdout:

# Default: just the file path
chartroom bar --csv data.csv
# /path/to/chart.png

# Markdown image syntax
chartroom bar --csv data.csv -f markdown --alt "Sales by region"
# ![Sales by region](/path/to/chart.png)

# HTML img tag
chartroom bar --csv data.csv -f html --alt "Sales by region"
# <img src="/path/to/chart.png" alt="Sales by region">

# JSON with path and alt text
chartroom bar --csv data.csv -f json
# {"path": "/path/to/chart.png", "alt": "Bar chart of value by name — ..."}

# Just the alt text
chartroom bar --csv data.csv -f alt
# Bar chart of value by name — alice: 10, bob: 20, charlie: 15

When --alt is omitted, alt text is auto-generated from the chart title (if set) or from the chart type and data. Small datasets get all values listed; larger datasets get a summary with range and extremes.

Alt text generation

Chartroom automatically generates descriptive alt text for every chart, making output accessible to screen readers and useful in documentation. You can use --alt to provide your own alt text, or let chartroom generate it from the chart type and data.

The auto-generated alt text adapts to both chart type and dataset size:

  • Bar, line, and scatter charts — Small datasets (6 rows or fewer) list every value (e.g. Bar chart of value by name — alice: 10, bob: 20, charlie: 15). Larger datasets summarize the count, range, and extremes (e.g. Bar chart of population by city. 10 points, ranging from 17118 (Dhaka) to 37400 (Tokyo)). Multiple y-columns are noted as additional series.
  • Pie charts — Small datasets show each category with its percentage (e.g. Pie chart showing Rent (57%), Food (19%), Transport (10%), Other (14%)). Larger datasets list the top 3 categories by share.
  • Histograms — Small datasets list all values. Larger datasets describe the distribution range (e.g. Histogram of 10 score values ranging from 76 to 95).

If a --title is set, it is prepended to the generated alt text (e.g. Team Scores. Bar chart of value by name — alice: 10, bob: 20, charlie: 15). The --alt option overrides this entirely with custom text. The alt text is embedded automatically when using -f markdown, -f html, or -f json output formats, or can be printed on its own with -f alt.

See the alt text demo for worked examples of every chart type and output format.

Styling

chartroom bar --csv data.csv --title "Sales" --xlabel "Region" --ylabel "Revenue" \
  --width 12 --height 8 --dpi 150 --style ggplot

Development

git clone https://github.com/simonw/chartroom
cd chartroom
uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chartroom-0.2.1.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chartroom-0.2.1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file chartroom-0.2.1.tar.gz.

File metadata

  • Download URL: chartroom-0.2.1.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chartroom-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ed4569606b707eca8799f68bedac39b794bdc3f607cdb5cff7c5a51384a653b0
MD5 d2071d0ac3347095d55e7dd526d4f99c
BLAKE2b-256 88654b342bb75a8581358b50d671b218f16d41095fafd5a07edea133b2fca472

See more details on using hashes here.

Provenance

The following attestation bundles were made for chartroom-0.2.1.tar.gz:

Publisher: publish.yml on simonw/chartroom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chartroom-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: chartroom-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chartroom-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5283a329e943b1ccabc92ad45712ee444e14bd212220bf371ff8623085ce04ca
MD5 4346a9c55c6c429f620bec7267357380
BLAKE2b-256 003a733cb04f3bf5e828a527a25dd2a51cb59e125b9acce0c42523f25b390b7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for chartroom-0.2.1-py3-none-any.whl:

Publisher: publish.yml on simonw/chartroom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page