Skip to main content

Draw simple plots and charts in the terminal using ASCII symbols

Project description

Terminal Plot MC

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

pip install term-plot

From source

git clone https://github.com/mosioc/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.1.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.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: term_plot_mc-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a56b7810eb1e37bfaa63a1d9000e0118c205841a3fecfa29a556b74faa92cb3d
MD5 41acdb132ccd74789184ecd833cf8115
BLAKE2b-256 084bff5aa9409030a0019008cf5f223523a6df440b77f36920b9a4878c60ba3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: term_plot_mc-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56e90fee7a1affae529400e44e05661ecb763614feab8b6cb53a0920e99a2ec8
MD5 9d8344dc9840ec2ed39210a76741001d
BLAKE2b-256 a8e5f06b87552981e7cb12368d5951d01bee89818ca74a0336cad5c2c069eabc

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