Austin Schuh | ab802d5 | 2020-07-03 18:11:11 -0700 | [diff] [blame^] | 1 | #define _USE_MATH_DEFINES |
| 2 | #include <cmath> |
| 3 | #include "../matplotlibcpp.h" |
| 4 | |
| 5 | using namespace std; |
| 6 | namespace plt = matplotlibcpp; |
| 7 | |
| 8 | int 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 | } |