Skip to content

Commit f89f140

Browse files
committed
Implemented wrapper corresponding to tick_params in matplotlib
1 parent 5adfbe0 commit f89f140

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

matplotlibcpp.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct _interpreter {
7373
PyObject *s_python_function_ylabel;
7474
PyObject *s_python_function_xticks;
7575
PyObject *s_python_function_yticks;
76+
PyObject *s_python_function_tick_params;
7677
PyObject *s_python_function_grid;
7778
PyObject *s_python_function_clf;
7879
PyObject *s_python_function_errorbar;
@@ -1370,6 +1371,30 @@ inline void yticks(const std::vector<Numeric> &ticks, const std::map<std::string
13701371
yticks(ticks, {}, keywords);
13711372
}
13721373

1374+
inline void tick_params(const std::map<std::string, std::string>& keywords, const std::string axis = "both")
1375+
{
1376+
// construct positional args
1377+
PyObject* args;
1378+
args = PyTuple_New(1);
1379+
PyTuple_SetItem(args, 0, PyString_FromString(axis.c_str()));
1380+
1381+
// construct keyword args
1382+
PyObject* kwargs = PyDict_New();
1383+
for (std::map<std::string, std::string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it)
1384+
{
1385+
PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str()));
1386+
}
1387+
1388+
1389+
PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_tick_params, args, kwargs);
1390+
1391+
Py_DECREF(args);
1392+
Py_DECREF(kwargs);
1393+
if (!res) throw std::runtime_error("Call to tick_params() failed");
1394+
1395+
Py_DECREF(res);
1396+
}
1397+
13731398
inline void subplot(long nrows, long ncols, long plot_number)
13741399
{
13751400
// construct positional args

0 commit comments

Comments
 (0)