term-plot-mc 0.1.2
Draw simple plots and charts in the terminal using ASCII symbols
License: MIT
Requires Python: >=3.8
Keywords: terminal, ascii, plot, chart, visualization, cli

# Terminal Plot

> Draw beautiful plots and charts in your terminal using ASCII and Unicode symbols

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

## 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 source

```bash
git clone https://github.com/mosioc/term-plot.git
cd term-plot
pip install -e .
```

## Quick Start

### Bar Chart

```python
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

```python
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

```python
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

```python
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

```python
# 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

```python
# With colors (default)
chart = BarChart(data, labels=labels, color=True)

# Without colors
chart = BarChart(data, labels=labels, color=False)
```

### Size Control

```python
# 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:

```bash
cd examples
python demo_all.py
```

## Testing

```bash
# 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](LICENSE) file for details.

## Acknowledgments

- Inspired by various terminal plotting libraries
- Unicode block elements from the Unicode standard
- ANSI color codes for terminal colors