Skip to main content

Draw simple plots and charts in the terminal using ASCII symbols

Project description

Terminal Plot

Draw beautiful plots and charts in your terminal using ASCII and Unicode symbols

License: MIT Python 3.8+

Features

  • Bar Charts - Horizontal and vertical bar charts for categorical data
  • Line Charts - Single and multi-series line plots with automatic scaling
  • Scatter Plots - Visualize correlations and relationships
  • Histograms - Show data distributions with customizable bins
  • Dual Modes - Beautiful Unicode symbols or ASCII for compatibility
  • Color Support - Optional ANSI colors for better visualization
  • Zero Dependencies - Pure Python, works anywhere
  • Lightweight - Fast and minimal resource usage

Installation

From PyPI (once published)

pip install term-plot

From source

git clone https://github.com/yourusername/term-plot.git
cd term-plot
pip install -e .

Quick Start

Bar Chart

from term_plot import BarChart

# Simple horizontal bar chart
data = [23, 45, 12, 67, 34, 89, 56]
labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']

chart = BarChart(data, labels=labels, title="Daily Sales", width=50)
print(chart.horizontal())

# Vertical bar chart
chart = BarChart(data, labels=labels, title="Daily Sales", height=15)
print(chart.vertical())

Line Chart

from term_plot import LineChart

# Single series
data = [1, 3, 7, 4, 8, 6, 9, 12, 10]
chart = LineChart(data, title="Temperature Over Time", width=60, height=15)
print(chart.plot())

# Multiple series
data = {
    "Product A": [5, 7, 9, 12, 15, 18, 20],
    "Product B": [3, 5, 8, 10, 12, 15, 17]
}
chart = LineChart(data, title="Sales Comparison", width=70, height=20)
print(chart.plot())

Scatter Plot

from term_plot import ScatterPlot

x_data = [1, 2, 3, 4, 5, 6, 7, 8, 9]
y_data = [2, 4, 3, 5, 7, 6, 8, 9, 8]

chart = ScatterPlot(x_data, y_data, title="Correlation Plot", width=50, height=15)
print(chart.plot())

Histogram

from term_plot import Histogram
import random

# Generate sample data
data = [random.gauss(50, 15) for _ in range(1000)]

chart = Histogram(data, bins=15, title="Test Score Distribution", width=60, height=15)
print(chart.plot())

Customization Options

ASCII vs Unicode

# Unicode mode (default) - prettier but requires Unicode support
chart = BarChart(data, labels=labels, use_unicode=True)

# ASCII mode - works everywhere
chart = BarChart(data, labels=labels, use_unicode=False)

Colors

# With colors (default)
chart = BarChart(data, labels=labels, color=True)

# Without colors
chart = BarChart(data, labels=labels, color=False)

Size Control

# Custom width and height
chart = LineChart(data, width=80, height=25)

Examples

Check out the examples/ directory for more:

  • bar_chart_example.py - Various bar chart styles
  • line_chart_example.py - Line chart examples including sine waves
  • demo_all.py - Comprehensive demo of all chart types

Run examples:

cd examples
python demo_all.py

Testing

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run tests with coverage
pytest --cov=term_plot

Requirements

  • Python 3.8 or higher
  • No external dependencies!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by various terminal plotting libraries
  • Unicode block elements from the Unicode standard
  • ANSI color codes for terminal colors

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

term_plot_mc-0.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

term_plot_mc-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file term_plot_mc-0.1.0.tar.gz.

File metadata

  • Download URL: term_plot_mc-0.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for term_plot_mc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 75a8727cf9c0471d5a9d0202ec9ebbc03286f0b2e5a5fdde34783462d76921a0
MD5 a59c46a93a610ba69533e207073d2041
BLAKE2b-256 9741fe67ef8f32afa22f3169853d44ac57c22ace48dee4ba85a1b670c7d2cd31

See more details on using hashes here.

File details

Details for the file term_plot_mc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: term_plot_mc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for term_plot_mc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0225dc28638cac034d599ea0065d09ad75145dcb0e9553003e46d8ca4dcee475
MD5 f8aaf3208fe5fb0c410fa3573505d9bb
BLAKE2b-256 be23d14ead48a663a9c0d35d40da03b949ba0a8e5b91ad034dad4eed36085171

See more details on using hashes here.

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