xplot

  • Interactive plotting for Jupyter notebook
  • Based on bqplot javascript side

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

xpl::linear_scale sx, sy;

auto ax_x = xpl::axis_generator(sx)
    .label("x")
    .finalize();

auto ax_y = xpl::axis_generator(sy)
    .label("y")
    .orientation("vertical")
    .side("left")
    .finalize();

xpl::lines line(sx, sy);
line.x = std::vector<double>({0, 20});
line.y = std::vector<double>({5, 8});

In [ ]:
auto fig1 = xpl::figure_generator()
    .padding_x(0.025)
    .padding_y(0.025)
    .finalize();

fig1.add_mark(line);
fig1.add_axis(ax_x);
fig1.add_axis(ax_y);
fig1

In [ ]:
#include <xtensor/xtensor.hpp>

line.x = xt::arange<double>(0, 20, 0.5);
line.y = xt::sin(xt::arange<double>(0, 20, 0.5) / 2);

In [ ]:
#include <chrono>
#include <thread>

for (auto i : xt::arange<double>(10.))
{
    line.x = xt::arange<double>(0, 20, 0.5);
    line.y = xt::sin(xt::arange<double>(0, 20, 0.5) / (10. - i));
    ax_x.label = "x = " + std::to_string(i);
    std::this_thread::sleep_for(std::chrono::milliseconds(300));
}

In [ ]: