@@ -1174,6 +1174,9 @@ bool errorbar(const std::vector<NumericX> &x, const std::vector<NumericY> &y, co
11741174template <typename Numeric>
11751175bool named_plot (const std::string& name, const std::vector<Numeric>& y, const std::string& format = " " )
11761176{
1177+ // Make sure python is initialized.
1178+ detail::_interpreter::get ();
1179+
11771180 PyObject* kwargs = PyDict_New ();
11781181 PyDict_SetItemString (kwargs, " label" , PyString_FromString (name.c_str ()));
11791182
@@ -1198,6 +1201,9 @@ bool named_plot(const std::string& name, const std::vector<Numeric>& y, const st
11981201template <typename Numeric>
11991202bool named_plot (const std::string& name, const std::vector<Numeric>& x, const std::vector<Numeric>& y, const std::string& format = " " )
12001203{
1204+ // Make sure python is initialized.
1205+ detail::_interpreter::get ();
1206+
12011207 PyObject* kwargs = PyDict_New ();
12021208 PyDict_SetItemString (kwargs, " label" , PyString_FromString (name.c_str ()));
12031209
@@ -1223,6 +1229,9 @@ bool named_plot(const std::string& name, const std::vector<Numeric>& x, const st
12231229template <typename Numeric>
12241230bool named_semilogx (const std::string& name, const std::vector<Numeric>& x, const std::vector<Numeric>& y, const std::string& format = " " )
12251231{
1232+ // Make sure python is initialized.
1233+ detail::_interpreter::get ();
1234+
12261235 PyObject* kwargs = PyDict_New ();
12271236 PyDict_SetItemString (kwargs, " label" , PyString_FromString (name.c_str ()));
12281237
@@ -1248,6 +1257,9 @@ bool named_semilogx(const std::string& name, const std::vector<Numeric>& x, cons
12481257template <typename Numeric>
12491258bool named_semilogy (const std::string& name, const std::vector<Numeric>& x, const std::vector<Numeric>& y, const std::string& format = " " )
12501259{
1260+ // Make sure python is initialized.
1261+ detail::_interpreter::get ();
1262+
12511263 PyObject* kwargs = PyDict_New ();
12521264 PyDict_SetItemString (kwargs, " label" , PyString_FromString (name.c_str ()));
12531265
@@ -1273,6 +1285,9 @@ bool named_semilogy(const std::string& name, const std::vector<Numeric>& x, cons
12731285template <typename Numeric>
12741286bool named_loglog (const std::string& name, const std::vector<Numeric>& x, const std::vector<Numeric>& y, const std::string& format = " " )
12751287{
1288+ // Make sure python is initialized.
1289+ detail::_interpreter::get ();
1290+
12761291 PyObject* kwargs = PyDict_New ();
12771292 PyDict_SetItemString (kwargs, " label" , PyString_FromString (name.c_str ()));
12781293
0 commit comments