@@ -24,6 +24,10 @@ namespace matplotlibcpp {
24
24
PyObject *s_python_function_xlim;
25
25
PyObject *s_python_function_ylim;
26
26
PyObject *s_python_function_title;
27
+ PyObject *s_python_function_axis;
28
+ PyObject *s_python_function_xlabel;
29
+ PyObject *s_python_function_ylabel;
30
+ PyObject *s_python_function_grid;
27
31
PyObject *s_python_empty_tuple;
28
32
29
33
/* For now, _interpreter is implemented as a singleton since its currently not possible to have
@@ -62,6 +66,10 @@ namespace matplotlibcpp {
62
66
s_python_function_legend = PyObject_GetAttrString (pymod, " legend" );
63
67
s_python_function_ylim = PyObject_GetAttrString (pymod, " ylim" );
64
68
s_python_function_title = PyObject_GetAttrString (pymod, " title" );
69
+ s_python_function_axis = PyObject_GetAttrString (pymod, " axis" );
70
+ s_python_function_xlabel = PyObject_GetAttrString (pymod, " xlabel" );
71
+ s_python_function_ylabel = PyObject_GetAttrString (pymod, " ylabel" );
72
+ s_python_function_grid = PyObject_GetAttrString (pymod, " grid" );
65
73
s_python_function_xlim = PyObject_GetAttrString (pymod, " xlim" );
66
74
67
75
s_python_function_save = PyObject_GetAttrString (pylabmod, " savefig" );
@@ -72,8 +80,13 @@ namespace matplotlibcpp {
72
80
|| !s_python_function_plot
73
81
|| !s_python_function_legend
74
82
|| !s_python_function_xlim
83
+ || !s_python_function_ylim
75
84
|| !s_python_function_title
76
- || !s_python_function_ylim)
85
+ || !s_python_function_axis
86
+ || !s_python_function_xlabel
87
+ || !s_python_function_ylabel
88
+ || !s_python_function_grid
89
+ )
77
90
{ throw std::runtime_error (" Couldnt find required function!" ); }
78
91
79
92
if (!PyFunction_Check (s_python_function_show)
@@ -82,8 +95,13 @@ namespace matplotlibcpp {
82
95
|| !PyFunction_Check (s_python_function_plot)
83
96
|| !PyFunction_Check (s_python_function_legend)
84
97
|| !PyFunction_Check (s_python_function_xlim)
98
+ || !PyFunction_Check (s_python_function_ylim)
85
99
|| !PyFunction_Check (s_python_function_title)
86
- || !PyFunction_Check (s_python_function_ylim))
100
+ || !PyFunction_Check (s_python_function_axis)
101
+ || !PyFunction_Check (s_python_function_xlabel)
102
+ || !PyFunction_Check (s_python_function_ylabel)
103
+ || !PyFunction_Check (s_python_function_grid)
104
+ )
87
105
{ throw std::runtime_error (" Python object is unexpectedly not a PyFunction." ); }
88
106
89
107
s_python_empty_tuple = PyTuple_New (0 );
@@ -258,9 +276,62 @@ namespace matplotlibcpp {
258
276
PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_title , args);
259
277
if (!res) throw std::runtime_error (" Call to title() failed." );
260
278
261
- // if PyDeCRFF, the show function doesn't wook on Mac OS
279
+ // if PyDeCRFF, the function doesn't work on Mac OS
262
280
}
263
281
282
+ inline void axis (const std::string &axisstr)
283
+ {
284
+ PyObject* str = PyString_FromString (axisstr.c_str ());
285
+ PyObject* args = PyTuple_New (1 );
286
+ PyTuple_SetItem (args, 0 , str);
287
+
288
+ PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_axis , args);
289
+ if (!res) throw std::runtime_error (" Call to title() failed." );
290
+
291
+ // if PyDeCRFF, the function doesn't work on Mac OS
292
+ }
293
+
294
+
295
+
296
+ inline void xlabel (const std::string &str)
297
+ {
298
+ PyObject* pystr = PyString_FromString (str.c_str ());
299
+ PyObject* args = PyTuple_New (1 );
300
+ PyTuple_SetItem (args, 0 , pystr);
301
+
302
+ PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_xlabel , args);
303
+ if (!res) throw std::runtime_error (" Call to xlabel() failed." );
304
+
305
+ // if PyDeCRFF, the function doesn't work on Mac OS
306
+ }
307
+
308
+ inline void ylabel (const std::string &str)
309
+ {
310
+ PyObject* pystr = PyString_FromString (str.c_str ());
311
+ PyObject* args = PyTuple_New (1 );
312
+ PyTuple_SetItem (args, 0 , pystr);
313
+
314
+ PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_ylabel , args);
315
+ if (!res) throw std::runtime_error (" Call to ylabel() failed." );
316
+
317
+ // if PyDeCRFF, the function doesn't work on Mac OS
318
+ }
319
+
320
+ inline void grid (bool flag)
321
+ {
322
+ PyObject* pyflag = flag ? Py_True : Py_False;
323
+
324
+ PyObject* args = PyTuple_New (1 );
325
+ PyTuple_SetItem (args, 0 , pyflag);
326
+
327
+ PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_grid , args);
328
+ if (!res) throw std::runtime_error (" Call to grid() failed." );
329
+
330
+ // if PyDeCRFF, the function doesn't work on Mac OS
331
+ }
332
+
333
+
334
+
264
335
inline void show ()
265
336
{
266
337
PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_show , detail::_interpreter::get ().s_python_empty_tuple );
0 commit comments