Browse Source

Add example of quiver plot

Alex Dewar 6 years ago
parent
commit
c1ad253e74
2 changed files with 20 additions and 0 deletions
  1. 20 0
      examples/quiver.cpp
  2. BIN
      examples/quiver.png

+ 20 - 0
examples/quiver.cpp

@@ -0,0 +1,20 @@
+#include "../matplotlibcpp.h"
+
+namespace plt = matplotlibcpp;
+
+int main()
+{
+    // u and v are respectively the x and y components of the arrows we're plotting
+    std::vector<int> x, y, u, v;
+    for (int i = -5; i <= 5; i++) {
+        for (int j = -5; j <= 5; j++) {
+            x.push_back(i);
+            u.push_back(-i);
+            y.push_back(j);
+            v.push_back(-j);
+        }
+    }
+
+    plt::quiver(x, y, u, v);
+    plt::show();
+}

BIN
examples/quiver.png