Giter Club home page Giter Club logo

plotty's Introduction

Plotty: C++ Interface to Matplotlib

image

Principles

  • plotty::plot(...) automatically creates a new figure
  • plotty::show() shows the results of the plot
  • calls to plotty::plot(...) go to the same plot until plotty::show() is called
  • by default, calls to plotty::show() are blocking and execution continues only after the plot window is closed

Simple plot of a vector:

// Std Vector:
std::vector<double> v({1, 2, 3, 4});
plotty::plot(v);
plotty::show();

// Eigen Types:
Eigen::VectorXd w(100);
w.setRandom();
plotty::plot(w)
plotty::show();

Plot x and y

Eigen::VectorXd t(100);
t.setLinSpaced(100, 0, 20);
Eigen::VectorXd v(100);
v.setRandom();
plotty::plot(t, v);
plotty::show();

Subplots

plotty::subplot(3, 1, 1);
plotty::plot(v1);
plotty::subplot(3, 1, 2);
plotty::plot(v2);
plotty::subplot(3, 1, 3);
plotty::plot(v2);
plotty::plot();

Histogram

The histogram function only exposes the bins, data and type parameters of matplotlibs histogram function.

plotty::hist(v, 10, "bar");
plotty::show();

Formatting

All functions accept optional format arguments (plotty::plot(x, y, format) or plotty::plot(y, format)). The expected format strings are equivalent to the matplotlib format strings:

plotty::plot(t, v, "rx"); // red x'es
plotty::show();

Multiple open Plots

plotty::show(false) opens a non-blocking window. You have to open a new figure to get a second plot ( plotty::figure()). The final figure should be opened in blocking mode to keep all windows open.

plotty::plot(v1);
plotty::show(false); // show non-blocking

...

plotty::figure(); // new figure
plotty::plot(v2)
plotty::show(false); // open non-blocking

...

plotty::figure();
plotty::plot(v3);
plotty::show(); // blocking to keep figures 1-3 open.

plotty::figure() accepts a string argument that labels / identifies a specific plot.

Style and Labels

plotty::plot(t, x);
plotty::xlabel("time [s]");
plotty::ylabel("Position [m]");
plotty::title("Position over time");
plotty::xlim(t_start, t_end);
plotty::ylim(0, x_max);

plotty's People

Contributors

burrimi avatar eggerk avatar helenol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.