#define _USE_MATH_DEFINES #include #include #include #include using namespace std; namespace plt = matplotlibcpp; int main() { // Prepare data int n = 500; xt::xtensor i = xt::linspace(0, (n-1), n); std::array shape{static_cast(n)}; xt::xtensor w(shape); w.fill(2.0); xt::xtensor x = xt::square(i); xt::xtensor y = xt::sin(2 * xt::numeric_constants::PI * i / 360.0); xt::xtensor z = xt::log(i); // Set the "super title" plt::suptitle("My plot"); plt::subplot(1, 2, 1); plt::plot(x, y+2, "r-"); plt::subplot(1, 2, 2); plt::plot(x-50000, z-2, "k-"); // Add some text to the plot plt::text(100, 90, "Hello!"); // Show plots plt::show(); }