blob: bee322e02b02a2073789424d7c04b563b5e26263 [file] [log] [blame]
Austin Schuhab802d52020-07-03 18:11:11 -07001#define _USE_MATH_DEFINES
2#include <cmath>
3#include "../matplotlibcpp.h"
4
5using namespace std;
6namespace plt = matplotlibcpp;
7
8int main()
9{
10 // Prepare data
11 int n = 500;
12 std::vector<double> x(n), y(n), z(n), w(n,2);
13 for(int i=0; i<n; ++i) {
14 x.at(i) = i;
15 y.at(i) = sin(2*M_PI*i/360.0);
16 z.at(i) = 100.0 / i;
17 }
18
19 // Set the "super title"
20 plt::suptitle("My plot");
21 plt::subplot(1, 2, 1);
22 plt::plot(x, y, "r-");
23 plt::subplot(1, 2, 2);
24 plt::plot(x, z, "k-");
25 // Add some text to the plot
26 plt::text(100, 90, "Hello!");
27
28
29 // Show plots
30 plt::show();
31}