@@ -23,6 +23,7 @@ namespace matplotlibcpp {
2323 PyObject *s_python_function_legend;
2424 PyObject *s_python_function_xlim;
2525 PyObject *s_python_function_ylim;
26+ PyObject *s_python_function_title;
2627 PyObject *s_python_empty_tuple;
2728
2829 /* For now, _interpreter is implemented as a singleton since its currently not possible to have
@@ -60,6 +61,7 @@ namespace matplotlibcpp {
6061 s_python_function_plot = PyObject_GetAttrString (pymod, " plot" );
6162 s_python_function_legend = PyObject_GetAttrString (pymod, " legend" );
6263 s_python_function_ylim = PyObject_GetAttrString (pymod, " ylim" );
64+ s_python_function_title = PyObject_GetAttrString (pymod, " title" );
6365 s_python_function_xlim = PyObject_GetAttrString (pymod, " xlim" );
6466
6567 s_python_function_save = PyObject_GetAttrString (pylabmod, " savefig" );
@@ -70,6 +72,7 @@ namespace matplotlibcpp {
7072 || !s_python_function_plot
7173 || !s_python_function_legend
7274 || !s_python_function_xlim
75+ || !s_python_function_title
7376 || !s_python_function_ylim)
7477 { throw std::runtime_error (" Couldnt find required function!" ); }
7578
@@ -79,6 +82,7 @@ namespace matplotlibcpp {
7982 || !PyFunction_Check (s_python_function_plot)
8083 || !PyFunction_Check (s_python_function_legend)
8184 || !PyFunction_Check (s_python_function_xlim)
85+ || !PyFunction_Check (s_python_function_title)
8286 || !PyFunction_Check (s_python_function_ylim))
8387 { throw std::runtime_error (" Python object is unexpectedly not a PyFunction." ); }
8488
@@ -244,6 +248,19 @@ namespace matplotlibcpp {
244248 Py_DECREF (res);
245249 }
246250
251+
252+ inline void title (const std::string &titlestr)
253+ {
254+ PyObject* pytitlestr = PyString_FromString (titlestr.c_str ());
255+ PyObject* args = PyTuple_New (1 );
256+ PyTuple_SetItem (args, 0 , pytitlestr);
257+
258+ PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_title , args);
259+ if (!res) throw std::runtime_error (" Call to title() failed." );
260+
261+ // if PyDeCRFF, the show function doesn't wook on Mac OS
262+ }
263+
247264 inline void show ()
248265 {
249266 PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_show , detail::_interpreter::get ().s_python_empty_tuple );
0 commit comments