C++ recipes Python scripts Adapters

Example Recipes

40+ runnable C++ and Python programs covering every major Spectra feature.

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++)

ExampleDescription
basic_line.cppMinimal line plot
easy_api_demo.cppEasy API progressive complexity showcase
easy_realtime_demo.cppMulti-signal sensor dashboard with tabs
live_stream.cppReal-time streaming data
animated_scatter.cppAnimated scatter plot
multi_subplot.cppGrid-based subplot layout
multi_figure_demo.cppMultiple figures with tabs
multi_window_tabs_demo.cppTab tear-off and multi-window
plot_styles_demo.cppAll 18 markers, dash patterns, format strings
stats_demo.cppBox plot, violin, histogram, bar chart
empty_launch_csv.cppEmpty canvas + CSV data loading
comprehensive_subplot_demo.cppFull subplot grid feature tour
multi_window_demo.cppIndependent OS windows, peer-equivalent
eigen_demo.cppPlot directly from Eigen matrices / vectors
logger_example.cppSpectra structured logging
shapes_demo.cpp2D shape primitives overlay

3D Visualization

ExampleDescription
demo_3d.cpp3D scatter, line, surface, mesh showcase
surface_3d.cpp3D surface with colormap
lit_surface_demo.cppBlinn-Phong lit surface with materials
transparency_demo.cppTransparent surfaces, wireframe, painter's sort
mind_blowing_3d.cppAdvanced 3D visualization
mode_transition_demo.cppAnimated 2D↔3D view switching
axes3d_demo.cpp3D axes / grid / tick label rendering
simple_3d_scatter.cppMinimal 3D scatter plot
parametric_3d_line.cppParametric 3D curves
shapes3d_demo.cpp3D primitives (cubes, spheres, arrows)
realtime_3d_stream.cppLive-streaming 3D data
camera_animation_3d.cppScripted 3D camera fly-through

Animation & Recording

ExampleDescription
advanced_animation_demo.cppFrame updates, pacing, timeline workflows
timeline_animation_demo.cppTimeline editor with keyframes
timeline_curve_demo.cppAnimation curve editor
camera_animator_demo.cppCamera orbit and turntable animation
offscreen_export.cppHeadless PNG export
video_record.cppMP4 recording via ffmpeg

UI & Extensibility

ExampleDescription
shortcut_config_demo.cppCustom keybinding persistence
plugin_api_demo.cppPlugin system demonstration
qt_embed_demo.cppNative Qt + Vulkan integration — see Qt Embedding
embed_cpp_demo.cppC++ embed surface (host any OS window)
easy_embed_demo.cppHeadless one-liner rendering — see guide
knob_demo.cppInteractive knob overlay widgets
shortcut_usage_demo.cppDefault shortcut tour
axes_menu_demo.cppAxes context menu customisation
legend_panel_test.cppLegend panel layout

Topics & Multi-Process

ExampleDescription
topic_publisher.cppPublish a named topic to spectra-backend — see Topics guide
multiproc_demo.shEnd-to-end daemon + window agent walkthrough

WebGPU / WASM

ExampleDescription
webgpu_demo.cpp2D plotting via WebGPU — see WebGPU guide
webgpu_shell.htmlHTML shell for the Emscripten build

ROS2 Demos

ExampleDescription
ros2_demo.cppMinimal ROS2 subscriber + plot — see ROS2 Adapter
ros2_ui_preview.cppROS2 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

Python Examples

Located in python/examples/:

ExampleDescription
basic_line.pySimple line plot
easy_3d.py3D plotting from Python
easy_live_dashboard.pyLive streaming dashboard
easy_multi_live.pyMulti-signal live streams
easy_subplots.pySubplot layouts
# Run Python examples
cd python && pip install -e ".[dev]"
python examples/basic_line.py
python examples/easy_live_dashboard.py

ROS2 Launch Files

Located in examples/ros2_launch/:

FileDescription
imu_monitor.launch.pyLinear acceleration + angular velocity from sensor_msgs/Imu
nav_dashboard.launch.pycmd_vel + odom fields for navigation monitoring
bag_replay.launch.pyOpen 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.