Created
March 9, 2019 20:11
-
-
Save olilarkin/36186efba47bf19ff024be2459501995 to your computer and use it in GitHub Desktop.
header to setup xeus-cling with matplotlib-cpp in jupyter-notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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