10000 Add example of quiver plot · OhHandsome/matplotlib-cpp@c1ad253 · GitHub
[go: up one dir, main page]

Skip to content

Commit c1ad253

Browse files
alexdewarlava
authored andcommitted
Add example of quiver plot
1 parent 697054c commit c1ad253

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

examples/quiver.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "../matplotlibcpp.h"
2+
3+
namespace plt = matplotlibcpp;
4+
5+
int main()
6+
{
7+
// u and v are respectively the x and y components of the arrows we're plotting
8+
std::vector<int> x, y, u, v;
9+
for (int i = -5; i <= 5; i++) {
10+
for (int j = -5; j <= 5; j++) {
11+
x.push_back(i);
12+
u.push_back(-i);
13+
y.push_back(j);
14+
v.push_back(-j);
15+
}
16+
}
17+
18+
plt::quiver(x, y, u, v);
19+
plt::show();
20+
}

examples/quiver.png

38.8 KB
Loading

0 commit comments

Comments
 (0)
0