Running Examples
# Build examples
cmake -B build -DSPECTRA_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
# Run
./build/examples/basic_line
./build/examples/demo_3d
./build/examples/easy_api_demo
# Windows
.\build\examples\Release\basic_line.exe
Core Plotting (C++)
| Example | Description |
|---|---|
basic_line.cpp | Minimal line plot |
easy_api_demo.cpp | Easy API progressive complexity showcase |
easy_realtime_demo.cpp | Multi-signal sensor dashboard with tabs |
live_stream.cpp | Real-time streaming data |
animated_scatter.cpp | Animated scatter plot |
multi_subplot.cpp | Grid-based subplot layout |
multi_figure_demo.cpp | Multiple figures with tabs |
multi_window_tabs_demo.cpp | Tab tear-off and multi-window |
plot_styles_demo.cpp | All 17 marker shapes, dash patterns, format strings |
stats_demo.cpp | Box plot, violin, histogram, bar chart |
grid_plots_demo.cpp | imshow, a labelled heatmap, contour and contourf with colorbars |
twinx_demo.cpp | Second y axis on the right sharing the x axis (twinx) |
precision_demo.cpp | Log-log axes and epoch timestamps kept exact with double-precision data |
plot_extras_demo.cpp | Step lines, dense-line rendering, annotation boxes, halos and rotation |
empty_launch_csv.cpp | Empty canvas + CSV data loading |
comprehensive_subplot_demo.cpp | Full subplot grid feature tour |
multi_window_demo.cpp | Independent OS windows, peer-equivalent |
eigen_demo.cpp | Plot directly from Eigen matrices / vectors |
logger_example.cpp | Spectra structured logging |
shapes_demo.cpp | 2D shape primitives overlay |
next_level_scientific.cpp | GPU colormapped scatter and native uncertainty band |
3D Visualization
| Example | Description |
|---|---|
demo_3d.cpp | 3D scatter, line, surface, mesh showcase |
surface_3d.cpp | 3D surface with colormap |
lit_surface_demo.cpp | Blinn-Phong lit surface with materials |
transparency_demo.cpp | Transparent surfaces, wireframe, painter's sort |
mind_blowing_3d.cpp | Advanced 3D visualization |
mode_transition_demo.cpp | Animated 2D↔3D view switching |
axes3d_demo.cpp | 3D axes / grid / tick label rendering |
simple_3d_scatter.cpp | Minimal 3D scatter plot |
parametric_3d_line.cpp | Parametric 3D curves |
shapes3d_demo.cpp | 3D primitives (cubes, spheres, arrows) |
realtime_3d_stream.cpp | Live-streaming 3D data |
camera_animation_3d.cpp | Scripted 3D camera fly-through |
depth_cues_3d.cpp | Depth shading, surface edge lines and floor contours |
Python Examples
Located in python/examples/; the full list is in its README.
| Example | Description |
|---|---|
easy_minimal.py | The simplest possible example: one line to plot |
easy_one_liner.py | A gallery of one-line plots |
easy_subplots.py | Several subplots in one window |
easy_3d.py | 3D one-liners: helix, scatter cloud, surface |
easy_showcase.py | Every Easy API feature in one script |
easy_live_dashboard.py | sp.live() callback-driven live dashboard |
streaming_update.py | Series.append() and FramePacer at 60 FPS |
topic_publisher.py | Publish a named topic and drag it onto a plot |
easy_embed_demo.py | Render to pixels or files without a window |
qt_backend_demo.py | matplotlib-style Qt canvas with a navigation toolbar |
notebook_widget.ipynb | Live, pannable plots in Jupyter (spectra.notebook) |
pip install spectra-plot
python python/examples/easy_minimal.py
python python/examples/easy_live_dashboard.py
Rust Examples
Located in rust/examples/; they need spectra-backend on your PATH (see the Rust README).
| Example | Description |
|---|---|
basic.rs | Two lines and a legend |
gallery.rs | Every chart type, saved as PNG |
live_stream.rs | Append at 60 fps from your own loop |
animate.rs | Timed animation driven by a slider |
topic_publisher.rs | Publish topics from Rust |
topic_subscriber.rs | Plot topics live in a window |
cd rust
cargo run --example basic
cargo run --example gallery -- out
Animation & Recording
| Example | Description |
|---|---|
advanced_animation_demo.cpp | Frame updates, pacing, timeline workflows |
timeline_animation_demo.cpp | Timeline editor with keyframes |
timeline_curve_demo.cpp | Animation curve editor |
camera_animator_demo.cpp | Camera orbit and turntable animation |
offscreen_export.cpp | Headless PNG export |
video_record.cpp | MP4 recording via ffmpeg |
UI & Extensibility
| Example | Description |
|---|---|
shortcut_config_demo.cpp | Custom keybinding persistence |
plugin_api_demo.cpp | Plugin system demonstration |
qt_embed_demo.cpp | Native Qt + Vulkan integration — see Qt Embedding |
embed_cpp_demo.cpp | C++ embed surface (host any OS window) |
easy_embed_demo.cpp | Headless one-liner rendering — see guide |
knob_demo.cpp | Interactive knob overlay widgets |
interactive_ref_demo.cpp | Drag sliders to move reference lines and retune a curve live |
shortcut_usage_demo.cpp | Default shortcut tour |
axes_menu_demo.cpp | Axes context menu customisation |
Topics & Multi-Process
| Example | Description |
|---|---|
topic_publisher.cpp | Publish a named topic to spectra-backend — see Topics guide |
multiproc_demo.sh | End-to-end daemon + window agent walkthrough |
WebGPU / WASM
| Example | Description |
|---|---|
webgpu_demo.cpp | 2D plotting via WebGPU — see WebGPU guide |
webgpu_shell.html | HTML shell for the Emscripten build |
ROS2 Demos
| Example | Description |
|---|---|
ros2_demo.cpp | Minimal ROS2 subscriber + plot — see ROS2 Adapter |
ros2_ui_preview.cpp | ROS2 panel UI preview without a live graph |
PX4 / ULog
The PX4 adapter ships as a standalone spectra-px4 binary rather than an example program. See the PX4 Adapter guide for ULog and MAVLink workflows.
./build/spectra-px4 flight.ulg
./build/spectra-px4 --connect --port 14540
ROS2 Launch Files
Located in examples/ros2_launch/:
| File | Description |
|---|---|
imu_monitor.launch.py | Linear acceleration + angular velocity from sensor_msgs/Imu |
nav_dashboard.launch.py | cmd_vel + odom fields for navigation monitoring |
bag_replay.launch.py | Open a rosbag by path with configurable rate and loop |
ros2 launch spectra imu_monitor.launch.py
ros2 launch spectra nav_dashboard.launch.py cmd_vel:=/cmd_vel_mux/input/navi
ros2 launch spectra bag_replay.launch.py bag:=/data/run42.mcap rate:=2.0
Use this page as your team onboarding index. For full API details, see the Feature Guide. For build instructions, see Getting Started.