GitHub mirror of our basic C++ plotting library

Basic C++ plots

This is a minimal header-only and dependency-free C++ plotting library.

It's maintained mostly for internal Signalsmith Audio use, so I'm adding features as I need them.

example plot

Design choices

  • SVG output only
  • auto-styled lines and fills
    • simultaneous colour/dash/hatch sequences for accessibility
    • styling done via (customisable) CSS where possible
    • custom JS (included as source or URL)
  • explicit labelling on lines, or legends
  • values labelled with three levels: major/minor/tick
    • no explicit axis-lines, use major gridlines instead
  • simplifies paths
    • attempts not to draw out-of-view data
    • drops points along almost-straight lines
  • each plot's edge can have multiple partial axes
  • basic grid (each row/column stretches to contain its contents)

Limitations

  • only 2D plots supported
  • no automatic label placement or de-collision
  • text lengths are heuristically estimated

How to use

All you need is the header file:

#include "plot.h";

View the API docs for complete info.

Basic example: drawing lines

Here's a minimal example, which sets up a 2D plot, adds some grid-lines/ticks:

// Set up a plot
signalsmith::plot::Plot2D plot;

// Place the grid/ticks
plot.x.majors(0, 10).tick(5).minor(3.5);
ploy.y.major(0);

// If you don't set the scale, it will guess from data/ticks
plot.x.linear(0, 15);
// You can use custom scales, using any function
// (or lambda) which accepts/returns `double`
plot.y.range(std::log, 1, 1000);

// Set up a line
auto &line = plot.line();
for (auto &p : points) {
	// Add points as x/y pairs
	line.add(p.x, p.y);
}
// or from array (using `.size()` if not specified)
line.addArray(xArr, yArr);

plot.write("example.svg");

More examples

See examples.cpp for code examples. Here are the images generated by that code:

Default plot style Custom plot style Style sequence Intersecting circles Multiple axes Legend Grid

API principles

You create a top-level object, which could be a Figure or a Plot2D:

signalsmith::plot::Plot2D plot;

When you create a sub-object (line, sub-plot, etc.), you are returned a reference. These elements are deliberately not copyable, so if you use auto instead of auto & it will complain.

auto &line = plot.line();

Many methods return a reference to the object, allowing you to chain them together, e.g.:

plot.x.major(0, 10).minor(5);

Development

Testing

There aren't any unit tests, just a visual check of the example plots.

License

Released as 0BSD. If you need anything else, get in touch. 🙂

Similar Resources

The artifact associated with our ISSTA 2021 paper "Seed Selection for Successful Fuzzing"

Seed Selection for Successful Fuzzing The artifact associated with our ISSTA 2021 paper "Seed Selection for Successful Fuzzing". While our primary art

Dec 7, 2022

Source code from 068A, our 64k demo presented at Syntax 2017

068A source code dump This is a dump of the source code for the engine, graphics tool and player for 068A, our 64k demo released at Syntax 2017. It's

Jan 2, 2023

Our Ludum Dare 49 contribution

LudumDare49 - Un-stabled Submission to Ludum Dare 49 Build instructions: git submodule update --init mkdir build && cd build cmake .. (This needs to b

Apr 5, 2022

Source Code and Embedded Design of Our Factory Robot at AUTCup 2015 Competitions

Source Code and Embedded Design of Our Factory Robot at AUTCup 2015 Competitions

AUTCup 2015 @Factory Robot This repository contains the source code and embedded design of our @Factory robot at AUTCup 2015 competitions. The robot w

Oct 20, 2021

Code for our ECE445/ME470 design: Wireless Charging Table with Automatic Alignment

Code for our ECE445/ME470 design: Wireless Charging Table with Automatic Alignment

Qi Wireless Charging Table with Automatic Alignment Code for ECE445/ME470 Senior Design Project SP21 at ZJUI. Team 24: Kaiwen Cao, Tianyi Han, Tingkai

May 1, 2022

Our very own ransomware for Linux

quierollorar Our very own ransomware for Linux quierollorar.sh encripta todo el contenido de la carpeta private/ parodellorar.sh desencripta todo el c

Nov 9, 2021

This repository contains the tools we used in our research on the Google Titan M chip

Titan M tools In this repository, we publish the tools we used in our research on the Google Titan M chip. We presented our results at Black Hat EU 21

Dec 5, 2022

Repository for the taproot-based rewrite of our 2021 development platform

Repository for the taproot-based rewrite of our 2021 development platform

taproot-mdev2021 This is a blank project fully configured for use of Taproot. It is designed to be a starting point for your own RoboMaster software p

Dec 28, 2022
Related tags
DISLIN is a high-level plotting library developed by Helmut Michels at the Max Planck Institute.

Harbour bindings for DISLIN, is a high level library of subroutines and functions that display data graphically.

Dec 10, 2021
Ancient Northwestern University Dept. of Geological Sciences plotting software

nplot Ancient Northwestern University Dept. of Geological Sciences plotting software Consists of: library routines (libloc) Fortran-callable routine (

Nov 21, 2021
CQC (Charmed Quark Controller) a commercial grade, full featured, software based automation system. CQC is built on our CIDLib C++ development system, which is also available here on GitHub.

The CQC Automation System What It Is CQC is a commercial quality, software based automation system, suitable for residential or commercial application

Dec 13, 2022
this is very basic version for our dataset validation, only change the path, and align the frame of vio and Groundtruth
this is very basic version for our dataset validation, only change the path, and align the frame of vio and Groundtruth

VINS-Fusion for UrbanNavDataset Evaluation 1. Prerequisites please refer to VINS-Fusion Github 2. Build mkdir catkin/src cd catkin/src mkdir result cd

Dec 9, 2022
ESP32 + GitHub Actions + Husarnet. A boilerplate project for ESP32 allowing in-field firmware update using GitHub Actions workflow.

esp32-internet-ota ESP32 + GitHub Actions + Husarnet. A boilerplate project for ESP32 allowing in-field firmware update using GitHub Actions workflow.

Sep 22, 2022
Itpp - IT++ library mirror/fork. C++ library of mathematical, signal processing and communication classes and functions.

Introduction ************ IT++ is a C++ library of mathematical, signal processing and communication classes and functions. Its main use is in simula

Oct 20, 2022
a undetectable tool by modify odyssey, support sign disable & dylib injection, test on iphoneX(13.5.1 expolit by FreeTheSandbox), our qqgroup is 703156427

a undetectable ios root access tool by modify odyssey, support sign disable & dylib injection, test on iphoneX(13.5.1 expolit by FreeTheSandbox), our

Nov 22, 2021
our supper awesome kernel and user space system

osakauss our super awesome kernel and user space system memory layout The kernel is loaded at 0x00100000. kmalloc initially uses 'placement' allocatio

Aug 26, 2021
Archer is the codename for our EPD laptop prototype with custom-made motherboard
Archer is the codename for our EPD laptop prototype with custom-made motherboard

Archer is the codename of our 1st EPD laptop prototype with custom-designed motherboard and 3D-printed chassis. Specifications The specification liste

Oct 12, 2022
This is the repo for the microcontroller part of project Cleanurge - a scalable IoT powered waste management system, our solution towards a greener world.
This is the repo for the microcontroller part of project Cleanurge - a scalable IoT powered waste management system, our solution towards a greener world.

Cleanurge A scalable waste management system powered by IoT. There are 3 repositories for the entire cleanurge system in total cleanurge-mcu: Containi

Oct 11, 2021