quiver.cpp 447 B

1234567891011121314151617181920
  1. #include "../matplotlibcpp.h"
  2. namespace plt = matplotlibcpp;
  3. int main()
  4. {
  5. // u and v are respectively the x and y components of the arrows we're plotting
  6. std::vector<int> x, y, u, v;
  7. for (int i = -5; i <= 5; i++) {
  8. for (int j = -5; j <= 5; j++) {
  9. x.push_back(i);
  10. u.push_back(-i);
  11. y.push_back(j);
  12. v.push_back(-j);
  13. }
  14. }
  15. plt::quiver(x, y, u, v);
  16. plt::show();
  17. }