10BC0 matplotlibcpp.h: fix initialization for python >= 3.8 · LipsonX/matplotlib-cpp@d772437 · GitHub
[go: up one dir, main page]

Skip to content

Commit d772437

Browse files
committed
matplotlibcpp.h: fix initialization for python >= 3.8
1 parent b87d8be commit d772437

File tree

2 files changed

+431
-376
lines changed

2 files changed

+431
-376
lines changed

examples/span.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
//
44
#include "../matplotlibcpp.h"
55

6+
#include <map>
67
#include <span>
8+
#include <vector>
79

810
using namespace std;
911
namespace plt = matplotlibcpp;
@@ -18,7 +20,21 @@ int main()
1820
3, 3, 3, 3
1921
};
2022

23+
// vector<double> xticks {1, 2, 3, 4};
24+
// vector<string> xlabels {"a", "b", "c", "d"};
25+
vector<double> xticks {1, 1.5, 2, 2.5, 3, 3.5, 4};
26+
vector<string> xlabels {"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg"};
27+
28+
// https://matplotlib.org/stable/api/text_api.html#matplotlib.text.Text
29+
map<string, string> kwargs {{"rotation", "45"},
30+
{"fontsize", "xx-large"},
31+
{"color", "m"}
32+
};
33+
2134
plt::plot(span(t, 4), span(data, 12));
35+
// plt::xticks(xticks, xlabels);
36+
plt::xticks(xticks, xlabels, kwargs);
37+
plt::grid(true);
2238
plt::show();
2339

2440
plt::detail::_interpreter::kill();

0 commit comments

Comments
 (0)
0