From ee1683fc3d9e45de315384722c7c484fdd97376a Mon Sep 17 00:00:00 2001 From: acxz <17132214+acxz@users.noreply.github.com> Date: Sat, 11 Apr 2020 20:10:29 -0400 Subject: [PATCH] ensure interpreter is initialized for suptitle & subplot --- matplotlibcpp.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/matplotlibcpp.h b/matplotlibcpp.h index 0112344..9649010 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -1611,6 +1611,9 @@ inline void tick_params(const std::map& keywords, cons inline void subplot(long nrows, long ncols, long plot_number) { + // Make sure interpreter is initialized + detail::_interpreter::get(); + // construct positional args PyObject* args = PyTuple_New(3); PyTuple_SetItem(args, 0, PyFloat_FromDouble(nrows)); @@ -1670,6 +1673,9 @@ inline void title(const std::string &titlestr, const std::map &keywords = {}) { + // Make sure interpreter is initialized + detail::_interpreter::get(); + PyObject* pysuptitlestr = PyString_FromString(suptitlestr.c_str()); PyObject* args = PyTuple_New(1); PyTuple_SetItem(args, 0, pysuptitlestr);