SigPack - the C++ signal processing library
latex.cpp

The Gnuplot output terminal 'epslatex' generates two output files, one .eps with the actual plot and one file .tex with the text in Latex format. To include the file use \input{filename.tex}

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}
\begin{figure}
\input{test.tex}
\end{figure}
\end{document}

Output

latex.png

Source

#include "sigpack.h"
using namespace arma;
using namespace sp;
int main()
{
int N = 512;
vec x(N), y(N);
gplot gp;
x = linspace(-5, 5, N);
y = exp(-(x - 1) % (x - 1) / datum::pi);
gp.set_output("test.tex");
gp.label(-4, 0.5, " $f(x)=e^{-\\\\frac{(x-1)^2}{\\\\pi}} $");
gp.xlim(-5, 5);
gp.plot_add(x, y, "");
gp.plot_show();
return 0;
}