Skip to content
smpratherPublic

About

Plot arbitrary data vs. zero-based time with plugins for custom data file parsers

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

time-plot

Plot arbitrary time-series data (non-calendar x-axis) into self-contained HTML using uPlot, with a pluggable parser system and expression-based derived traces.

What It Does

  • Loads one or more input files via auto-discovered parser plugins.
  • Filters series by glob (-F) or regex (-R) patterns.
  • Converts all data to base units and aligns traces to a common time grid.
  • Renders sampled logic signals as stacked step lanes so signals do not overlap.
  • Evaluates derived traces from expressions (-e "name=expr"), including chained expressions.
  • Renders interactive offline HTML plots with summary statistics and input/source metadata.
  • Supports dual y-axes (up to two distinct y-units per plot).
  • Sorts all traces by RMS (descending) for readability.
  • Opens the result in your browser automatically.

Requirements

  • Python >=3.14
  • uv

Installation

Install as a user tool (recommended):

uv tool install git+https://github.com/smprather/time-plot

Then run anywhere:

time-plot --help

Quick Start

Render a single input file:

time-plot -f path/to/data.csv

Render file with derived expressions:

time-plot -f sine.csv -e "sum=sine+sine" -e "rate=ddt(sum)"

Running with no -f flags opens the built-in sine.csv example.

CLI Usage

time-plot [OPTIONS] -f <files...> [-F <glob>] [-R <regex>] [-e <name=expr>] ...

Source and Filter Flags (order-sensitive)

  • -f <path...>: Load one or more source files. Repeatable. Shell globs work (e.g., -f *.csv).
  • -F <glob>: Glob filter on series names; binds to the preceding -f group. No glob chars → substring match (foo → *foo*).
  • -R <regex>: Regex filter on series names; same binding semantics as -F. ANDed with -F if both given. Both orders work (-F g -R r and -R r -F g); repeated -F/-R keeps the last value; a filter before any -f is an error.
  • -e "name=expr": Define a named expression (see Expressions).
  • -i, --case-insensitive: Apply -F/-R filters case-insensitively.

Options

  • -o, --output FILE: Output HTML path. Defaults to /tmp/$USER/time_plot.html.
  • --open-browser / --no-open-browser: Open the output in the default browser after writing (default: --open-browser).
  • -l, --list-series: List available series for each file (with -F/-R applied) and exit.
  • --ascii: Print an ASCII plot to the terminal (via plotext) and exit; no HTML is written.
  • --ascii-width COLS: ASCII plot width in columns (default: terminal width).
  • --ascii-height ROWS: ASCII plot height in rows (default: 30).
  • --no-color: Disable ANSI colors in terminal output (auto-disabled when piped).
  • --rms-filter THRESHOLD: Exclude series whose RMS is below the threshold (same units as the data).
  • --show-rms-histogram: Print an ASCII histogram of per-series RMS values and exit.
  • --add-plugins-dir DIRECTORY: Additional plugin directory (repeatable; last given has highest precedence).
  • --list-plugins: List all discovered plugins with short descriptions and exit.
  • --plugin-help PLUGIN: Show detailed help for a named plugin and exit.
  • --parser-options TEXT: Comma-separated key=value pairs passed to parser plugins.
  • --version: Show the version and exit.

Environment Variables

  • TIME_PLOT_EXTRA_PLUGINS_PATH: Colon-separated list of additional plugin directories.

Examples

time-plot -f signal.csv
time-plot -f signal.csv --ascii
time-plot -f logic.vcd
time-plot -f data.ptiavg -F 'rtr_0*' -l
time-plot -f data.ptiavg -F 'rtr_0*' -e "total=sum(*|rtr_0*)"
time-plot -f a.ptiavg -F 'mac*' -f b.ptiavg -F 'cts*' -e "diff=mac|inst-cts|inst"

Note: Positional arguments (without -f) are not accepted and will produce an error.

Output

  • Default output path: /tmp/$USER/time_plot.html.
  • Plot HTML is self-contained (inlines uPlot JS/CSS assets) — works offline.
  • Interactive chart with mousewheel zoom and closest-series highlighting for non-logic plots.
  • Summary statistics table (Peak |y|, Average, RMS) for non-logic plots.
  • Logic traces use stacked lane rendering with vertical transitions at change timestamps; signal names appear as y-axis ticks, with no Logic y-axis title, no cursor-nearest highlighting, and no numeric summary table. Logic legend rows toggle all rendered helper lines for the signal and show 0/1/X/Z values.
  • Source table showing input file paths or expression text per trace.
  • All traces sorted by RMS (descending).
  • --ascii renders analog traces as a static terminal plot instead of HTML (no interactivity). Logic traces are rejected in this mode; NaN gaps break the line. Up to two y-units are supported (second unit on the right axis).

Supported Input Formats

1) Voltage/Current vs. Time CSV

  • Plugin ID: voltage-or-current-vs-time
  • File type: .csv
  • Two-column header: time(<unit>),voltage(<unit>) or time(<unit>),current(<unit>)
time(ns),voltage(mv)
0,0
1,0.5

2) SPICE PWL

  • Plugin ID: spice-pwl
  • Parses SPICE netlists containing pwl voltage or current sources.
  • Supports line continuations with leading +.
  • Each PWL source becomes one series.
  • Parser option naming_method: element_name (default, uses the SPICE element name, e.g. vclk) or positive_node_name (uses the positive terminal name, e.g. clk).
time-plot -f spice_pwl.spi --parser-options naming_method=positive_node_name

3) VCD Logic

  • Plugin ID: vcd
  • File type: