numerics 0.1.0
Loading...
Searching...
No Matches
plot.hpp File Reference

Matplotlib-style plotting via a gnuplot pipe. More...

#include <cstdio>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  num::Series
 Ordered (x, y) series. More...
 
class  num::Gnuplot
 

Namespaces

namespace  num
 
namespace  num::plt
 
namespace  num::plt::detail
 

Typedefs

using num::Point = std::pair< double, double >
 (x, y) data point.
 

Functions

void num::apply_siam_style (Gnuplot &gp)
 Apply SIAM-style theme to a raw Gnuplot pipe.
 
void num::set_loglog (Gnuplot &gp)
 
void num::set_logx (Gnuplot &gp)
 
void num::save_png (Gnuplot &gp, const std::string &filename, int w=900, int h=600)
 

Detailed Description

Matplotlib-style plotting via a gnuplot pipe.

Requires gnuplot in PATH (runtime only – no link-time dependency).

Quick start

#include "numerics.hpp"
num::Vector t = ..., x = ...;
num::plt::plot(t, x, "signal");
num::plt::title("Damped oscillator");
num::plt::xlabel("t");
num::plt::ylabel("x(t)");
num::plt::show(); // opens gnuplot window; blocks until closed
num::plt::savefig("out.png"); // alternative: save to PNG

Multiple series on one figure:

num::plt::plot(t, x, "Verlet");
num::plt::plot(t, y, "RK4");
num::plt::legend();
num::plt::show();

Definition in file plot.hpp.