Colormap
As a convenience, the colors.h
header contains many functions to generate colors from strings and vice-versa.
More examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | #include <iostream>
#include <matplot/matplot.h>
#include <set>
#include <thread>
#include <vector>
int main() {
using namespace matplot;
std::vector<std::vector<double>> map = {{0, 0, 0.3}, {0, 0, 0.4},
{0, 0, 0.5}, {0, 0, 0.6},
{0, 0, 0.8}, {0, 0, 1}};
auto [x, y, z] = peaks();
surf(x, y, z);
colormap(map);
show();
return 0;
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | #include <matplot/matplot.h>
#include <vector>
int main() {
using namespace matplot;
auto [X, Y] = meshgrid(iota(-5, .5, 5));
auto Z = transform(
X, Y, [](double X, double Y) { return pow(X, 2) + pow(Y, 2); });
surf(X, Y, Z);
colorbar();
caxis({20, 50});
show();
return 0;
}
|