SciPlot Widget Demo Programs

# SciPlot Demo Programs

- Building
- xyplot — x/y plotter
  - Screen Shot
  - Usage
  - Input File Format
  - Sample Input File
- sciplot-realtime — Streaming real-time plotter

- SciPlot General Info
- Programmer's Documentation

## Building

Two demo programs are shipped with the source distribution. Both require GTK4, Cairo, and Pango (via `pkg-config`). Build with the standard autotools sequence:

`autoreconf -fi && ./configure && make`

The two programs produced are `sciplot-xyplot` and `sciplot-realtime`.

## sciplot-xyplot — x/y plotter

The `sciplot-xyplot` program takes a text file (or standard input) as input and plots the data as x/y or polar plots. More than one set of data may appear in a single plot frame, and more than one plot frame may be displayed at once. As shown in the screen shot, many widget features are available as interactive controls before generating a PostScript copy.

### Screen Shot

### Usage

`sciplot-xyplot [OPTION...] [FILE...]`

`sciplot-xyplot` accepts one or more input files on the command line, or reads from standard input if none are given. Use `--help` for a full option list and `--version` for version information.

### Input File Format

There are five commands recognised in the input file. Optional items are enclosed in [square brackets].

Title [title]
  Starts a new plot window, optionally setting the plot title.
Xaxis [label]
  Sets the x-axis label.
Yaxis [label]
  Sets the y-axis label.
Polar [rad]
  Switches the current plot to polar mode. Angles are in degrees by default; add the keyword `rad` for radians.
Line legend-label
  Begins a new data series. Data lines follow immediately; the parser continues reading pairs of numbers until it encounters another command or end-of-file. Values are separated by commas, equals signs, or whitespace; both coordinates must appear on the same line.

  The keyword `skip` may appear in place of a data line to break the line into disjoint segments (see `SCIPLOT_SKIP_VAL`).

Text labels should be enclosed in double-quote characters.

### Sample Input File

    Title="Crack Growth Comparison"
    Xaxis="Number of Cycles (kc)"
    Yaxis="Crack Depth (mm)"

    Line="25% strain"
    0.000000e+00    2.000000e+00
    1.373497e+02    2.500000e+00
    2.403780e+02    3.000000e+00
    skip
    3.205736e+02    3.500000e+00
    3.845680e+02    4.000000e+00

    Line="50% strain"
    0.000000e+00    2.000000e+00
    3.480081e+01    2.500000e+00
    6.082956e+01    3.000000e+00
    skip
    8.105608e+01    3.500000e+00
    9.719518e+01    4.000000e+00

    Line="100% strain"
    0.000000e+00    2.000000e+00
    4.212263e+00    2.500000e+00
    6.219232e+00    3.000000e+00
    7.458972e+00    3.500000e+00
    8.387889e+00    4.000000e+00

## sciplot-realtime — Streaming real-time plotter

`sciplot-realtime` reads whitespace- or comma-separated numeric data from standard input and updates the plot as each line arrives.

### Input format

One sample per line. Lines beginning with `#` are ignored.

Columns per line | Interpretation
--- | ---
1: y | Single Y series; X auto-increments from 0
2: x y | Explicit X and one Y series
N: x y1 y2 … | Explicit X and N−1 Y series

The number of series is fixed by the first data line. When standard input reaches EOF the plot window stays open for interactive use (axis toggles, PostScript export, etc.).

### Options

Option | Description
--- | ---
`-t, --title TEXT` | Plot title (default: "Real-time Data")
`-x, --xlabel TEXT` | X axis label
`-y, --ylabel TEXT` | Y axis label
`-l, --legend NAME,...` | Comma-separated series names
`-V, --version` | Show version and exit
`-h, --help` | Show help and exit

### Usage

`sciplot-realtime [OPTION...]`

Examples:

    # Plot a single sensor channel
    sensor-tool | sciplot-realtime --ylabel "Temperature (C)"

    # Plot multiple channels with named series
    multi-sensor | sciplot-realtime --legend "ch1,ch2,ch3" --xlabel "Sample"

    # Non-interactive preview of a data file
    sciplot-realtime < data.txt

    # Plot ping round-trip times
    ping host | awk '/time=/{gsub(/.*time=/,""); gsub(/ .*/,""); print}' \
              | sciplot-realtime --ylabel "RTT (ms)"

SciPlot : Programmer's Reference | Demo Programs

Originally by Rob McMullen. GTK4 port by Barak A. Pearlmutter. Updated: 2 Jun 2026