Skip to content

Repository files navigation

Simple Command-line Plotting Tool

License: MITVersionPython Version


A simple command-line plotting tool.

This project uses DuckDB for data loading and transformation, and tplot for terminal-based rendering. It supports multiple input formats (CSV, JSON, NDJSON, Parquet), SQL-style filtering, time-series bucketing with aggregation, and scatter plots with customizable markers.

Install

This project should not be confused for an older, abandoned project already on the package index by the same name. Install directly from GitHub:

uv tool install git+https://github.com/glentner/plot-cli

Usage

Usage:
plot [-h] [-v] [FILE] [-x NAME] [-y NAME] [--line | --scatter | --hist] ...
Simple command-line plotting tool.

Input Formats

By default, format is auto-detected from file extension. Use --format to override:

# CSV (default for stdin)
cat data.csv | plot -x timestamp -y value -T
# Parquet
plot data.parquet -x time -y metric
# JSON array
plot data.json --format json -x x -y y
# Newline-delimited JSON
plot logs.ndjson --format ndjson -x timestamp -y count

Filtering

Filter data using SQL WHERE clauses or datetime bounds:

# Custom WHERE clause
plot data.csv --where "value > 100 AND status = 'active'"# Datetime filtering (requires -x to specify timestamp column)
plot timeseries.csv -x timestamp -y value --after "2024-01-01" --before "2024-02-01"

Time-Series Bucketing

Aggregate time-series data into buckets using -B/--bucket with an aggregation method:

# 15-minute buckets with mean aggregation
plot metrics.csv -x timestamp -y value -T -B 15min --mean
# Hourly buckets with sum
plot events.csv -x time -y count -T -B 1h --sum
# Supported aggregation methods: --mean, --sum, --count, --min, --max, --first, --last

Bucket interval formats: 15min, 1h, 30m, 1d, 60s, or full syntax like 15 minutes.

Output Modes

Instead of plotting, output processed data as JSON or CSV:

# Output as JSON (useful for piping to jq)
plot data.csv --json --where "value > 50"# Output as CSV
plot data.parquet --csv -x timestamp -y value -B 1h --mean

Relative Time Scaling

Convert datetime axis to relative offset from start or end:

# Hours from start
plot timeseries.csv -x timestamp -y value -T -S +hours
# Minutes from end (negative offset)
plot timeseries.csv -x timestamp -y value -T -S -minutes

Options Reference

OptionDescription
-x, --xdata NAMEColumn for x-axis
-y, --ydata NAME...Column(s) for y-axis
--format NAMEInput format: csv, json, ndjson, parquet
--lineLine plot (default)
--scatterScatter plot
--marker CHARMarker character for scatter plots (default: )
--histHistogram
--where EXPRSQL WHERE clause for filtering
--after TIMEFilter rows after timestamp
--before TIMEFilter rows before timestamp
-T, --timeseriesTreat x-axis as datetime
-S, --scale SCALERelative offset (e.g., +hours, -days)
-B, --bucket INTERVALTime bucket interval (e.g., 15min, 1h)
-A, --agg-method NAMEAggregation: mean, sum, count, min, max, first, last
--mean, --sum, etc.Aggregation method aliases
-b, --bins NUMHistogram bins (default: 10)
-d, --densityShow histogram as percentage
-t, --title NAMEPlot title
-s, --size W,HPlot size in characters
-c, --color SEQComma-separated colors
-l, --legend POSLegend position
-X, --xlabel NAMEX-axis label
-Y, --ylabel NAMEY-axis label
--jsonOutput data as JSON
--csvOutput data as CSV
-h, --helpShow help
-v, --versionShow version

Scatter Plots

Render data as a scatter plot with an optional custom marker:

# Basic scatter plot
plot data.csv -x x -y y --scatter
# Scatter plot with custom marker
plot data.csv -x x -y y --scatter --marker x

Example

Using the basic line plot example from seaborn:

plot-cli example

About

Simple command-line plotting tool

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages