Skip to content

Instantly share code, notes, and snippets.

@olilarkin
Created March 9, 2019 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olilarkin/36186efba47bf19ff024be2459501995 to your computer and use it in GitHub Desktop.
Save olilarkin/36186efba47bf19ff024be2459501995 to your computer and use it in GitHub Desktop.
header to setup xeus-cling with matplotlib-cpp in jupyter-notebook
#pragma cling add_include_path("/usr/include/python2.7")
#pragma cling add_include_path("/Users/oli/Dev/matplotlib-cpp") // change to point to matplotlib-cpp.h
#pragma cling add_library_path("/usr/lib/python2.7")
#pragma cling load("python2.7")
#define WITHOUT_NUMPY 1
#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;
#include <string>
#include <fstream>
#include "xtl/xbase64.hpp"
#include "xeus/xjson.hpp"
namespace im
{
struct image
{
inline image(const std::string& filename)
{
std::ifstream fin(filename, std::ios::binary);
m_buffer << fin.rdbuf();
}
std::stringstream m_buffer;
};
xeus::xjson mime_bundle_repr(const image& i)
{
auto bundle = xeus::xjson::object();
bundle["image/png"] = xtl::base64encode(i.m_buffer.str());
return bundle;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment