Squashed 'third_party/matplotlib-cpp/' content from commit f994996

Change-Id: I2124d6ed85284acca42fc0e90f489f422e6e440a
git-subtree-dir: third_party/matplotlib-cpp
git-subtree-split: f994996e0724f30612154a26cbdc660ad9c51907
diff --git a/examples/animation.cpp b/examples/animation.cpp
new file mode 100644
index 0000000..d979430
--- /dev/null
+++ b/examples/animation.cpp
@@ -0,0 +1,36 @@
+#define _USE_MATH_DEFINES
+#include <cmath>
+#include "../matplotlibcpp.h"
+
+namespace plt = matplotlibcpp;
+
+int main()
+{
+	int n = 1000;
+	std::vector<double> x, y, z;
+
+	for(int i=0; i<n; i++) {
+		x.push_back(i*i);
+		y.push_back(sin(2*M_PI*i/360.0));
+		z.push_back(log(i));
+
+		if (i % 10 == 0) {
+			// Clear previous plot
+			plt::clf();
+			// Plot line from given x and y data. Color is selected automatically.
+			plt::plot(x, y);
+			// Plot a line whose name will show up as "log(x)" in the legend.
+			plt::named_plot("log(x)", x, z);
+
+			// Set x-axis to interval [0,1000000]
+			plt::xlim(0, n*n);
+
+			// Add graph title
+			plt::title("Sample figure");
+			// Enable legend.
+			plt::legend();
+			// Display plot continuously
+			plt::pause(0.01);
+		}
+	}
+}
diff --git a/examples/animation.gif b/examples/animation.gif
new file mode 100644
index 0000000..ef8eb5a
--- /dev/null
+++ b/examples/animation.gif
Binary files differ
diff --git a/examples/basic.cpp b/examples/basic.cpp
new file mode 100644
index 0000000..2b02f27
--- /dev/null
+++ b/examples/basic.cpp
@@ -0,0 +1,37 @@
+#define _USE_MATH_DEFINES
+#include <iostream>
+#include <cmath>
+#include "../matplotlibcpp.h"
+
+namespace plt = matplotlibcpp;
+
+int main() 
+{
+	// Prepare data.
+	int n = 5000;
+	std::vector<double> x(n), y(n), z(n), w(n,2);
+	for(int i=0; i<n; ++i) {
+		x.at(i) = i*i;
+		y.at(i) = sin(2*M_PI*i/360.0);
+		z.at(i) = log(i);
+	}
+
+	// Plot line from given x and y data. Color is selected automatically.
+	plt::plot(x, y);
+	// Plot a red dashed line from given x and y data.
+	plt::plot(x, w,"r--");
+	// Plot a line whose name will show up as "log(x)" in the legend.
+	plt::named_plot("log(x)", x, z);
+
+	// Set x-axis to interval [0,1000000]
+	plt::xlim(0, 1000*1000);
+
+	// Add graph title
+	plt::title("Sample figure");
+	// Enable legend.
+	plt::legend();
+	// save figure
+	const char* filename = "./basic.png";
+	std::cout << "Saving result to " << filename << std::endl;;
+	plt::save(filename);
+}
diff --git a/examples/basic.png b/examples/basic.png
new file mode 100644
index 0000000..eef82a2
--- /dev/null
+++ b/examples/basic.png
Binary files differ
diff --git a/examples/minimal.cpp b/examples/minimal.cpp
new file mode 100644
index 0000000..fbe1e1c
--- /dev/null
+++ b/examples/minimal.cpp
@@ -0,0 +1,8 @@
+#include "../matplotlibcpp.h"
+
+namespace plt = matplotlibcpp;
+
+int main() {
+    plt::plot({1,3,2,4});
+    plt::show();
+}
diff --git a/examples/minimal.png b/examples/minimal.png
new file mode 100644
index 0000000..0f6cf37
--- /dev/null
+++ b/examples/minimal.png
Binary files differ
diff --git a/examples/modern.cpp b/examples/modern.cpp
new file mode 100644
index 0000000..a8aa0c7
--- /dev/null
+++ b/examples/modern.cpp
@@ -0,0 +1,30 @@
+#define _USE_MATH_DEFINES
+#include <cmath>
+#include "../matplotlibcpp.h"
+
+using namespace std;
+namespace plt = matplotlibcpp;
+
+int main() 
+{
+	// plot(y) - the x-coordinates are implicitly set to [0,1,...,n)
+	//plt::plot({1,2,3,4}); 
+	
+	// Prepare data for parametric plot.
+	int n = 5000; // number of data points
+	vector<double> x(n),y(n); 
+	for(int i=0; i<n; ++i) {
+		double t = 2*M_PI*i/n;
+		x.at(i) = 16*sin(t)*sin(t)*sin(t);
+		y.at(i) = 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t);
+	}
+
+	// plot() takes an arbitrary number of (x,y,format)-triples. 
+	// x must be iterable (that is, anything providing begin(x) and end(x)),
+	// y must either be callable (providing operator() const) or iterable. 
+	plt::plot(x, y, "r-", x, [](double d) { return 12.5+abs(sin(d)); }, "k-");
+
+
+	// show plots
+	plt::show();
+}
diff --git a/examples/modern.png b/examples/modern.png
new file mode 100644
index 0000000..0c51555
--- /dev/null
+++ b/examples/modern.png
Binary files differ
diff --git a/examples/nonblock.cpp b/examples/nonblock.cpp
new file mode 100644
index 0000000..327d96c
--- /dev/null
+++ b/examples/nonblock.cpp
@@ -0,0 +1,46 @@
+#define _USE_MATH_DEFINES
+#include <cmath>
+#include "../matplotlibcpp.h"
+
+namespace plt = matplotlibcpp;
+
+
+using namespace matplotlibcpp;
+using namespace std;
+
+int main()
+{
+    // Prepare data.
+    int n = 5000;
+    std::vector<double> x(n), y(n), z(n), w(n,2);
+    for(int i=0; i<n; ++i) {
+        x.at(i) = i*i;
+        y.at(i) = sin(2*M_PI*i/360.0);
+        z.at(i) = log(i);
+    }
+
+    // Plot line from given x and y data. Color is selected automatically.
+    plt::subplot(2,2,1);
+    plt::plot(x, y);
+
+    // Plot a red dashed line from given x and y data.
+    plt::subplot(2,2,2);
+    plt::plot(x, w,"r--");
+
+    // Plot a line whose name will show up as "log(x)" in the legend.
+    plt::subplot(2,2,3);
+    plt::named_plot("log(x)", x, z);
+
+    // Set x-axis to interval [0,1000000]
+    plt::xlim(0, 1000*1000);
+
+    // Add graph title
+    plt::title("Sample figure");
+    // Enable legend.
+    plt::legend();
+
+    plt::show(false);
+
+    cout << "matplotlibcpp::show() is working in an non-blocking mode" << endl;
+    getchar();
+}
diff --git a/examples/xkcd.cpp b/examples/xkcd.cpp
new file mode 100644
index 0000000..9bf6454
--- /dev/null
+++ b/examples/xkcd.cpp
@@ -0,0 +1,21 @@
+#include "../matplotlibcpp.h"
+#include <vector>
+#include <cmath>
+
+namespace plt = matplotlibcpp;
+
+int main() {
+    std::vector<double> t(1000);
+    std::vector<double> x(t.size());
+
+    for(size_t i = 0; i < t.size(); i++) {
+        t[i] = i / 100.0;
+        x[i] = sin(2.0 * M_PI * 1.0 * t[i]);
+    }
+
+    plt::xkcd();
+    plt::plot(t, x);
+    plt::title("AN ORDINARY SIN WAVE");
+    plt::show();
+}
+
diff --git a/examples/xkcd.png b/examples/xkcd.png
new file mode 100644
index 0000000..c285e3d
--- /dev/null
+++ b/examples/xkcd.png
Binary files differ