@@ -61,6 +61,7 @@ struct _interpreter {
61
61
PyObject *s_python_function_imshow;
62
62
PyObject *s_python_function_scatter;
63
63
PyObject *s_python_function_subplot;
64
+ PyObject *s_python_function_subplot2grid;
64
65
PyObject *s_python_function_legend;
65
66
PyObject *s_python_function_xlim;
66
67
PyObject *s_python_function_ion;
@@ -193,6 +194,7 @@ struct _interpreter {
193
194
s_python_function_hist = safe_import (pymod," hist" );
194
195
s_python_function_scatter = safe_import (pymod," scatter" );
195
196
s_python_function_subplot = safe_import (pymod, " subplot" );
197
+ s_python_function_subplot2grid = safe_import (pymod, " subplot2grid" );
196
198
s_python_function_legend = safe_import (pymod, " legend" );
197
199
s_python_function_ylim = safe_import (pymod, " ylim" );
198
200
s_python_function_title = safe_import (pymod, " title" );
@@ -362,6 +364,9 @@ bool plot(const std::vector<Numeric> &x, const std::vector<Numeric> &y, const st
362
364
return res;
363
365
}
364
366
367
+ // TODO - it should be possible to make this work by implementing
368
+ // a non-numpy alternative for `get_2darray()`.
369
+ #ifndef WITHOUT_NUMPY
365
370
template <typename Numeric>
366
371
void plot_surface (const std::vector<::std::vector<Numeric>> &x,
367
372
const std::vector<::std::vector<Numeric>> &y,
@@ -453,6 +458,8 @@ void plot_surface(const std::vector<::std::vector<Numeric>> &x,
453
458
Py_DECREF (kwargs);
454
459
if (res) Py_DECREF (res);
455
460
}
461
+ #endif // WITHOUT_NUMPY
462
+
456
463
457
464
template <typename Numeric>
458
465
bool stem (const std::vector<Numeric> &x, const std::vector<Numeric> &y, const std::map<std::string, std::string>& keywords)
@@ -1073,7 +1080,6 @@ bool named_loglog(const std::string& name, const std::vector<Numeric>& x, const
1073
1080
PyTuple_SetItem (plot_args, 0 , xarray);
1074
1081
PyTuple_SetItem (plot_args, 1 , yarray);
1075
1082
PyTuple_SetItem (plot_args, 2 , pystring);
1076
-
1077
1083
PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_loglog , plot_args, kwargs);
1078
1084
1079
1085
Py_DECREF (kwargs);
@@ -1379,6 +1385,31 @@ inline void subplot(long nrows, long ncols, long plot_number)
1379
1385
Py_DECREF (res);
1380
1386
}
1381
1387
1388
+ void subplot2grid (long nrows, long ncols, long rowid=0 , long colid=0 , long rowspan=1 , long colspan=1 )
1389
+ {
1390
+ PyObject* shape = PyTuple_New (2 );
1391
+ PyTuple_SetItem (shape, 0 , PyLong_FromLong (nrows));
1392
+ PyTuple_SetItem (shape, 1 , PyLong_FromLong (ncols));
1393
+
1394
+ PyObject* loc = PyTuple_New (2 );
1395
+ PyTuple_SetItem (loc, 0 , PyLong_FromLong (rowid));
1396
+ PyTuple_SetItem (loc, 1 , PyLong_FromLong (colid));
1397
+
1398
+ PyObject* args = PyTuple_New (4 );
1399
+ PyTuple_SetItem (args, 0 , shape);
1400
+ PyTuple_SetItem (args, 1 , loc);
1401
+ PyTuple_SetItem (args, 2 , PyLong_FromLong (rowspan));
1402
+ PyTuple_SetItem (args, 3 , PyLong_FromLong (colspan));
1403
+
1404
+ PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_subplot2grid , args);
1405
+ if (!res) throw std::runtime_error (" Call to subplot2grid() failed." );
1406
+
1407
+ Py_DECREF (shape);
1408
+ Py_DECREF (loc);
1409
+ Py_DECREF (args);
1410
+ Py_DECREF (res);
1411
+ }
1412
+
1382
1413
inline void title (const std::string &titlestr, const std::map<std::string, std::string> &keywords = {})
1383
1414
{
1384
1415
PyObject* pytitlestr = PyString_FromString (titlestr.c_str ());
0 commit comments