rbc-tk9

rbc-tk9 (Refactored BLT Components) brings selected plotting and numerical components from BLT to Tcl/Tk 9. A graph can take its data directly from RBC vectors and redraw when their values change. All plot types can be exported to SVG, PostScript and PDF with either the native or the optional Cairo renderer.

Components

The following commands are in the ::rbc namespace.

  • graph — Cartesian plots with multiple axes, line and symbol elements, error bars, markers and legends.
  • trackgraph — Several plots in one widget, with shared X axes and independent Y axes. Each track can display lines, strips or bars.
  • barchart — Bar charts with normal, side-by-side, stacked or overlapping bars.
  • stripchart — Waveform displays built from independent line segments, suitable for continuously updated data.
  • polar — Complex-plane plots with a polar or Smith grid. Elements accept separate X and Y data or a complex vector.
  • graphtoolbar — A TclOO megawidget for zooming, panning, crosshairs, point inspection and legend controls.
  • vector — Double-precision real and complex vectors with arithmetic, expressions and change notifications.
  • spline — Natural cubic and shape-preserving quadratic interpolation, including parametric interpolation of complex vectors.
  • winop — Window operations and image-processing commands.

Documentation and source

Available platforms

RBC supports Tcl/Tk 9.0 and 9.1. Prebuilt packages are available for Tcl/Tk 9.1 on the following platforms.

  • Linux (X11) — Packaged as a .tar.gz archive.
  • Windows — Packaged as .zip archives for MSYS2/UCRT64 and Microsoft Visual C++ (MSVC). Choose the build that matches your Tcl/Tk installation.

Each platform offers a native-renderer build and a Cairo-enabled build for antialiased plotting. Both support SVG, PDF and PostScript export.

Download prebuilt packages

User-visible additions

rbc-tk9 is a full port of RBC (Refactored BLT Components) to Tcl/Tk 9. It supports Tcl/Tk 9.0 and 9.1 on Linux and Windows.

  • Multi-track plots. Stack traces on a shared X axis with independent Y scales, grids, legends and annotations. Tracks can be resized, reordered, scrolled or arranged side by side.
  • Polar and Smith charts. Plot Cartesian components, angle and radius, or a complex vector directly. Smith charts accept reflection coefficient, impedance or admittance and can overlay impedance and admittance grids.
  • Dense and streaming waveforms. On eligible line and strip traces, -decimate auto preserves the first, lowest, highest and last sample in each pixel column. Narrow spikes remain visible while the source vectors and exports retain full detail.
  • Graph interaction. The optional rbc::graphtoolbar provides zoom, pan, crosshairs and closest-point annotations that refresh as data changes. Axis-change events let applications synchronize plots. The -hideplot option keeps a hidden trace's legend entry available.
  • Plot styling. Lines and strips can show uncertainty as a filled band. Bars support alignment, offsets and error bars positioned on grouped or stacked bars. Markers include arrowheads, ellipses, arcs, chords and pie slices. The optional Cairo renderer adds antialiasing.
  • Numerical work in tclsh. Load rbc::vector to use real and complex vectors without a display. Operations include FFT and inverse FFT, frequency-bin and window generation, magnitude and phase extraction, and Douglas–Peucker polyline simplification.
  • Graphics export. All plot types, including track graphs and polar and Smith charts, export directly to SVG, PDF and PostScript without Cairo. Exports include axes, legends, markers and track layouts. SVG preserves editable text and can embed fonts. PDF embeds fonts by default so Unicode labels can be searched and copied. PostScript supports page size, orientation and EPS output. See the SVG , PDF and PostScript references.
  • Updated C vector interface. C extensions can create and access real and complex vectors through the public stubs API. After modifying vector data directly, an extension can notify clients of a whole-vector change with Rbc_VectorChanged() or identify the affected samples with Rbc_VectorChangedRange(). Extensions that only need vectors can use Rbc_VectorInitStubs without initializing Tk or opening a display. The existing real-vector API remains available.

Load the widgets with package require rbc, or the widgets and toolbar together with package require rbc::graphtoolbar. For numerical work without a display, use package require rbc::vector. A script can load Tk and the widgets later and keep the vectors it has already created.

Interactive demos

FFT and inverse FFT

Compare a signal with its inverse FFT reconstruction and inspect its amplitude spectrum and power spectral density.

Polyline simplification

Adjust the Douglas–Peucker tolerance to see which points are retained and how closely the simplified line follows the original waveform.

Static demos

Trackgraph demo

Examples of packages using RBC vectors

  • NgspiceTclBridge streams ngspice results into live RBC vectors, so an attached graph updates as simulation samples arrive. It can also take independent snapshots of real or complex traces.
  • tclsimrawreader reads selected traces or sample ranges from SPICE raw files into RBC vectors, allowing an application to plot part of a simulation without loading the entire dataset.
  • tclmeasure performs SPICE-style measurements on sampled waveforms. It accepts RBC vectors as inputs and can return vector-valued results as RBC vectors.
  • tclinterp interpolates sampled data using real RBC vectors for input and output. An application can supply a named destination vector that is already attached to a graph.
  • rfutil uses complex RBC vectors for two-port RF calculations. For example, it can convert a frequency sweep of S-parameters to impedance parameters and return each result as a complex vector.

Compatibility

package require rbc loads the traditional graph.tcl helper commands. Existing scripts can continue to enable interactions on individual graphs with commands such as Rbc_ZoomStack .g, Rbc_Crosshairs .g and Rbc_ActiveLegend .g.

New applications can load rbc::graphtoolbar with package require rbc::graphtoolbar. Use one interaction system per graph because the toolbar and the legacy helpers install overlapping event bindings. Different graphs in the same application can use different systems.

Copyright, licence and credits

RBC began as a refactoring of selected BLT 2.4z components for Tcl/Tk 8.5. The original RBC code is copyright 2009 Samuel Green, Nicholas Hudson, Stanton Sievers and Jarrod Stormo and is distributed under the BSD 3-Clause License. The inherited BLT code carries a separate permissive licence from Lucent Technologies, Inc. (copyright 1998). Both licence texts are included in the project's license.terms file.

Emiliano Gavilán ported RBC to Tcl/Tk 9.0. George Yashin maintains the current fork, which builds on Gavilán's Tcl/Tk 9 port .