@@ -47,6 +47,7 @@ struct _interpreter {
47
47
PyObject *s_python_function_hist;
48
48
PyObject *s_python_function_scatter;
49
49
PyObject *s_python_function_subplot;
50
+ PyObject *s_python_function_subplot2grid;
50
51
PyObject *s_python_function_legend;
51
52
PyObject *s_python_function_xlim;
52
53
PyObject *s_python_function_ion;
@@ -167,6 +168,7 @@ struct _interpreter {
167
168
s_python_function_hist = PyObject_GetAttrString (pymod," hist" );
168
169
s_python_function_scatter = PyObject_GetAttrString (pymod," scatter" );
169
170
s_python_function_subplot = PyObject_GetAttrString (pymod, " subplot" );
171
+ s_python_function_subplot2grid = PyObject_GetAttrString (pymod, " subplot2grid" );
170
172
s_python_function_legend = PyObject_GetAttrString (pymod, " legend" );
171
173
s_python_function_ylim = PyObject_GetAttrString (pymod, " ylim" );
172
174
s_python_function_title = PyObject_GetAttrString (pymod, " title" );
@@ -205,6 +207,7 @@ struct _interpreter {
205
207
|| !s_python_function_fill
206
208
|| !s_python_function_fill_between
207
209
|| !s_python_function_subplot
210
+ || !s_python_function_subplot2grid
208
211
|| !s_python_function_legend
209
212
|| !s_python_function_ylim
210
213
|| !s_python_function_title
@@ -243,6 +246,7 @@ struct _interpreter {
243
246
|| !PyFunction_Check (s_python_function_fill)
244
247
|| !PyFunction_Check (s_python_function_fill_between)
245
248
|| !PyFunction_Check (s_python_function_subplot)
249
+ || !PyFunction_Check (s_python_function_subplot2grid)
246
250
|| !PyFunction_Check (s_python_function_legend)
247
251
|| !PyFunction_Check (s_python_function_annotate)
248
252
|| !PyFunction_Check (s_python_function_ylim)
@@ -1026,7 +1030,6 @@ bool named_loglog(const std::string& name, const std::vector<Numeric>& x, const
1026
1030
PyTuple_SetItem (plot_args, 0 , xarray);
1027
1031
PyTuple_SetItem (plot_args, 1 , yarray);
1028
1032
PyTuple_SetItem (plot_args, 2 , pystring);
1029
-
1030
1033
PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_loglog , plot_args, kwargs);
1031
1034
1032
1035
Py_DECREF (kwargs);
@@ -1321,6 +1324,31 @@ inline void subplot(long nrows, long ncols, long plot_number)
1321
1324
Py_DECREF (res);
1322
1325
}
1323
1326
1327
+ void subplot2grid (long nrows, long ncols, long rowid=0 , long colid=0 , long rowspan=1 , long colspan=1 )
1328
+ {
1329
+ PyObject* shape = PyTuple_New (2 );
1330
+ PyTuple_SetItem (shape, 0 , PyLong_FromLong (nrows));
1331
+ PyTuple_SetItem (shape, 1 , PyLong_FromLong (ncols));
1332
+
1333
+ PyObject* loc = PyTuple_New (2 );
1334
+ PyTuple_SetItem (loc, 0 , PyLong_FromLong (rowid));
1335
+ PyTuple_SetItem (loc, 1 , PyLong_FromLong (colid));
1336
+
1337
+ PyObject* args = PyTuple_New (4 );
1338
+ PyTuple_SetItem (args, 0 , shape);
1339
+ PyTuple_SetItem (args, 1 , loc);
1340
+ PyTuple_SetItem (args, 2 , PyLong_FromLong (rowspan));
1341
+ PyTuple_SetItem (args, 3 , PyLong_FromLong (colspan));
1342
+
1343
+ PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_subplot2grid , args);
1344
+ if (!res) throw std::runtime_error (" Call to subplot2grid() failed." );
1345
+
1346
+ Py_DECREF (shape);
1347
+ Py_DECREF (loc);
1348
+ Py_DECREF (args);
1349
+ Py_DECREF (res);
1350
+ }
1351
+
1324
1352
inline void title (const std::string &titlestr, const std::map<std::string, std::string> &keywords = {})
1325
1353
{
1326
1354
PyObject* pytitlestr = PyString_FromString (titlestr.c_str ());
0 commit comments