Skip to main content

Beautiful ASCII charts for your terminal — bar, histogram, heatmap, box plot, and 11 more chart types with zero dependencies

Project description

textcharts

Beautiful text based charts for your terminal — zero dependencies.

15 chart types with Unicode box-drawing, ANSI colors, and automatic terminal width detection. Pure Python, no external dependencies, Python 3.10+.

Provenance

textcharts was extracted from the BenchBox project so the terminal charting layer could be used as a standalone library.

BenchBox remains the source of the most complete end-to-end usage examples for benchmarking and performance-analysis workflows. For canonical example-driven documentation, see the BenchBox documentation.

Install

pip install textcharts

Quick Start

from textcharts import BoxPlot, BoxPlotSeries

downtown = [1825, 1900, 1980, 2100, 2250, 2400, 2550, 2710, 2980]
riverside = [1450, 1525, 1600, 1680, 1750, 1820, 1950, 2080, 2220]
midtown = [1650, 1710, 1780, 1840, 1920, 2010, 2140, 2280, 2450]

series = [
    BoxPlotSeries(name="Downtown", values=downtown),
    BoxPlotSeries(name="Riverside", values=riverside),
    BoxPlotSeries(name="Midtown", values=midtown),
]
chart = BoxPlot(
    series=series,
    title="Apartment Rents",
    subtitle="Monthly rent distribution by neighborhood",
)
print(chart.render())

Box plot rendered in the terminal

Text output (greyscale)
Apartment Rents (Value)
               Monthly rent distribution by neighborhood
────────────────────────────────────────────────────────────────────────

                         ╷     ┌─────────┬──────────┐                ╷
Downtown                 ├─────│         │          │────────────────┤
                         ╵     └─────────┴──────────┘                ╵
           ╷    ┌─────┬──────┐          ╷
Riverside  ├────│     │      │──────────┤
           ╵    └─────┴──────┘          ╵
                  ╷    ┌────┬────────┐          ╷
Midtown           ├────│    │        │──────────┤
                  ╵    └────┴────────┘          ╵
           ───────────────────────────────────────────────────────────
           1.4K                       2.2K                        3.0K
                                Value →
           median  mean    std
           ──────  ────  ─────
Downtown     2.2K  2.3K  392.7
Riverside    1.8K  1.8K  257.6
Midtown      1.9K  2.0K  269.8

Chart Types

Chart Class Data Model
Bar chart BarChart BarData
Histogram Histogram HistogramBar
Heatmap Heatmap matrix + labels
Box plot BoxPlot BoxPlotSeries
Line chart LineChart LinePoint
Scatter plot ScatterPlot ScatterPoint
Comparison bar ComparisonBar ComparisonBarData
Diverging bar DivergingBar DivergingBarData
Summary box SummaryBox SummaryStats
Percentile ladder PercentileLadder PercentileData
Normalized speedup NormalizedSpeedup SpeedupData
Stacked bar StackedBar StackedBarData
Sparkline table SparklineTable SparklineTableData
CDF chart CDFChart CDFSeriesData
Rank table RankTable RankTableData

Public API

  • Chart classes: BarChart, Heatmap, LineChart, SummaryBox, etc.
  • Data models: BarData, HistogramBar, LinePoint, SummaryStats, etc.
  • Configuration: ChartOptions and ColorMode

CLI

Generate charts from the command line with JSON input:

# Pipe JSON data to any chart type
echo '[{"label": "Fiction", "value": 18.4}, {"label": "Comics", "value": 9.8}]' \
  | textcharts bar --title "Revenue" --no-color

# Read from a file
textcharts heatmap -f matrix.json --color-scheme sequential

# List all 15 chart types
textcharts list

# See data format and options for any chart type
textcharts scatter --help

See the input formats reference for the JSON schema of each chart type.

MCP Server

Use textcharts as an AI tool via the Model Context Protocol:

pip install textcharts[mcp]

Add to your MCP client config (Claude Desktop, Claude Code, etc.):

{
  "mcpServers": {
    "textcharts": {
      "command": "textcharts-mcp"
    }
  }
}

This exposes 17 tools: textcharts_bar, textcharts_heatmap, ..., textcharts_list, and textcharts_describe. See the MCP setup guide for full configuration options.

Configuration

from textcharts import ChartOptions, ColorMode

opts = ChartOptions(
    use_color=True,       # Auto-detect ANSI color support; set False to force plain text
    use_unicode=True,     # Unicode box-drawing characters
    width=80,             # Chart width (None for auto-detect)
    theme="dark",         # "dark" or "light"
)

use_color=True respects terminal detection and NO_COLOR. In non-interactive contexts, renders default to plain text without ANSI escapes.

Heatmaps support color_scheme="diverging" (default) or color_scheme="sequential".

Matrix-based APIs require exact dimensions:

  • len(row_labels) == len(matrix)
  • every matrix row length must equal len(col_labels)

Development

Install dev tools:

uv sync --group dev

Run the same checks used for release verification:

uv run --group dev ruff check src/ tests/
uv run --group dev python -m pytest -q
uv run --group dev sphinx-build -W -b html docs docs/_build/html
uv build

Project documentation lives under docs/ and is built with Sphinx.

If you want richer real-world examples beyond the standalone library docs, use the BenchBox documentation as the canonical reference for benchmark-oriented chart usage.

Golden regression snapshots live under tests/fixtures/golden/ascii/. To intentionally update them after a renderer change:

uv run --group dev python -m pytest tests/test_golden_output.py -q --update-golden

Features

  • Zero dependencies — pure Python, stdlib only
  • 15 chart types — from simple bars to heatmaps and CDF curves
  • Terminal-aware — auto-detects width, color support, and Unicode capability
  • Best/worst highlighting — automatic annotation of extreme values
  • Typed — full type hints with py.typed marker (PEP 561)

License

MIT

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

textcharts-0.1.1.tar.gz (3.2 MB view details)

Uploaded Source

Built Distribution

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

textcharts-0.1.1-py3-none-any.whl (85.0 kB view details)

Uploaded Python 3

File details

Details for the file textcharts-0.1.1.tar.gz.

File metadata

  • Download URL: textcharts-0.1.1.tar.gz
  • Upload date:
  • Size: 3.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for textcharts-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1c51497926629c6300d80718d3a3532451cd582d32d6135736659feabb10412e
MD5 68d430785de962a653745c71a16c6dc7
BLAKE2b-256 de1fd4d3c53348bf6a920086908f6f91db36e285a2484651635ec70498e0d4f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for textcharts-0.1.1.tar.gz:

Publisher: ci.yml on joeharris76/textcharts

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

File details

Details for the file textcharts-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for textcharts-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfbc3d76644130525f98608f404ca8501e8cd6a5a07c7c6e09ac9f0fd19838de
MD5 9444454ed8ade524b09f96e44e9e2bb9
BLAKE2b-256 f3b38a7dc3175a0047c6a42376e83c0bc9ce53468318ab2a3f3b5436c0c9bc83

See more details on using hashes here.

Provenance

The following attestation bundles were made for textcharts-0.1.1-py3-none-any.whl:

Publisher: ci.yml on joeharris76/textcharts

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