In [1]:
#include "xplot/xfigure.hpp"
#include "xplot/xmarks.hpp"
#include "xplot/xaxes.hpp"

In [2]:
std::size_t n = 200;

In [3]:
std::vector<double> x(n);

In [4]:
double h = 1./(n-1);
for (std::size_t i=0; i<n; ++i)
{
    x[i] = -5 + 10. * i * h;
}

In [5]:
std::vector<std::vector<double>> color(n, std::vector<double>(n));

In [6]:
for (std::size_t i=0; i<n; ++i)
{
    for (std::size_t j=0; j<n; ++j)
    {
        color[i][j] = std::cos(x[j]*x[j] + x[i]*x[i]);
    }
}

In [7]:
xpl::linear_scale xs, ys;
xpl::color_scale cs;
cs.scheme = "RdYlBu";
xpl::heat_map heatmap(x, x, color, xs, ys, cs);

In [8]:
xpl::figure fig;
fig.add_mark(heatmap);
fig.display()



In [9]:
fig.max_aspect_ratio = 1.;

In [10]:
fig.title = "Cosine";

In [11]:
xpl::axis hx(xs), hy(ys);
xpl::color_axis hc(cs);
hy.orientation = "vertical";
fig.add_axis(hx);
fig.add_axis(hy);
fig.add_axis(hc);

In [ ]: