@@ -1321,29 +1321,41 @@ inline void subplot(long nrows, long ncols, long plot_number)
1321
1321
Py_DECREF (res);
1322
1322
}
1323
1323
1324
- inline void title (const std::string &titlestr)
1324
+ inline void title (const std::string &titlestr, const std::map<std::string, std::string> &keywords = {} )
1325
1325
{
1326
1326
PyObject* pytitlestr = PyString_FromString (titlestr.c_str ());
1327
1327
PyObject* args = PyTuple_New (1 );
1328
1328
PyTuple_SetItem (args, 0 , pytitlestr);
1329
1329
1330
- PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_title , args);
1330
+ PyObject* kwargs = PyDict_New ();
1331
+ for (auto it = keywords.begin (); it != keywords.end (); ++it) {
1332
+ PyDict_SetItemString (kwargs, it->first .c_str (), PyUnicode_FromString (it->second .c_str ()));
1333
+ }
1334
+
1335
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_title , args, kwargs);
1331
1336
if (!res) throw std::runtime_error (" Call to title() failed." );
1332
1337
1333
1338
Py_DECREF (args);
1339
+ Py_DECREF (kwargs);
1334
1340
Py_DECREF (res);
1335
1341
}
1336
1342
1337
- inline void suptitle (const std::string &suptitlestr)
1343
+ inline void suptitle (const std::string &suptitlestr, const std::map<std::string, std::string> &keywords = {} )
1338
1344
{
1339
1345
PyObject* pysuptitlestr = PyString_FromString (suptitlestr.c_str ());
1340
1346
PyObject* args = PyTuple_New (1 );
1341
1347
PyTuple_SetItem (args, 0 , pysuptitlestr);
1342
1348
1343
- PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_suptitle , args);
1349
+ PyObject* kwargs = PyDict_New ();
1350
+ for (auto it = keywords.begin (); it != keywords.end (); ++it) {
1351
+ PyDict_SetItemString (kwargs, it->first .c_str (), PyUnicode_FromString (it->second .c_str ()));
1352
+ }
1353
+
1354
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_suptitle , args, kwargs);
1344
1355
if (!res) throw std::runtime_error (" Call to suptitle() failed." );
1345
1356
1346
1357
Py_DECREF (args);
1358
+ Py_DECREF (kwargs);
1347
1359
Py_DECREF (res);
1348
1360
}
1349
1361
@@ -1360,29 +1372,41 @@ inline void axis(const std::string &axisstr)
1360
1372
Py_DECREF (res);
1361
1373
}
1362
1374
1363
- inline void xlabel (const std::string &str)
1375
+ inline void xlabel (const std::string &str, const std::map<std::string, std::string> &keywords = {} )
1364
1376
{
1365
1377
PyObject* pystr = PyString_FromString (str.c_str ());
1366
1378
PyObject* args = PyTuple_New (1 );
1367
1379
PyTuple_SetItem (args, 0 , pystr);
1368
1380
1369
- PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_xlabel , args);
1381
+ PyObject* kwargs = PyDict_New ();
1382
+ for (auto it = keywords.begin (); it != keywords.end (); ++it) {
1383
+ PyDict_SetItemString (kwargs, it->first .c_str (), PyUnicode_FromString (it->second .c_str ()));
1384
+ }
1385
+
1386
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_xlabel , args, kwargs);
1370
1387
if (!res) throw std::runtime_error (" Call to xlabel() failed." );
1371
1388
1372
1389
Py_DECREF (args);
1390
+ Py_DECREF (kwargs);
1373
1391
Py_DECREF (res);
1374
1392
}
1375
1393
1376
- inline void ylabel (const std::string &str)
1394
+ inline void ylabel (const std::string &str, const std::map<std::string, std::string>& keywords = {} )
1377
1395
{
1378
1396
PyObject* pystr = PyString_FromString (str.c_str ());
1379
1397
PyObject* args = PyTuple_New (1 );
1380
1398
PyTuple_SetItem (args, 0 , pystr);
1381
1399
1382
- PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_ylabel , args);
1400
+ PyObject* kwargs = PyDict_New ();
1401
+ for (auto it = keywords.begin (); it != keywords.end (); ++it) {
1402
+ PyDict_SetItemString (kwargs, it->first .c_str (), PyUnicode_FromString (it->second .c_str ()));
1403
+ }
1404
+
1405
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_ylabel , args, kwargs);
1383
1406
if (!res) throw std::runtime_error (" Call to ylabel() failed." );
1384
1407
1385
1408
Py_DECREF (args);
1409
+ Py_DECREF (kwargs);
1386
1410
Py_DECREF (res);
1387
1411
}
1388
1412
0 commit comments