| 2 | #include <matplot/matplot.h> |
| 3 | |
| 4 | int main() { |
| 5 | using namespace matplot; |
| 6 | |
| 7 | fplot([](double x) { return sin(x); }, |
| 8 | std::array<double, 2>{-2 * pi, 2 * pi}); |
| 9 | grid(on); |
| 10 | title("sin(x) from -2π to 2π"); |
| 11 | xlabel("x"); |
| 12 | ylabel("y"); |
| 13 | |
| 14 | auto ax = gca(); |
| 15 | ax->x_axis().tick_values(iota(-2 * pi, pi / 2, 2 * pi)); |
| 16 | ax->x_axis().ticklabels( |
| 17 | {"-2π", "-3π/2", "-π", "-π/2", "0", "π/2", "π", "3π/2", "2π"}); |
| 18 | |
| 19 | show(); |
| 20 | return 0; |
| 21 | } |