Skip to content

Commit 8297ae8

Browse files
belreBenno Evers
authored andcommitted
Implemented wrapper corresponding to tick_params in matplotlib
1 parent 6fb6a91 commit 8297ae8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

matplotlibcpp.h

Lines changed: 26 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;
@@ -203,6 +204,7 @@ struct _interpreter {
203204
s_python_function_ylabel = safe_import(pymod, "ylabel");
204205
s_python_function_xticks = safe_import(pymod, "xticks");
205206
s_python_function_yticks = safe_import(pymod, "yticks");
207+
s_python_function_tick_params = safe_import(pymod, "tick_params");
206208
s_python_function_grid = safe_import(pymod, "grid");
207209
s_python_function_xlim = safe_import(pymod, "xlim");
208210
s_python_function_ion = safe_import(pymod, "ion");
@@ -1375,6 +1377,30 @@ inline void yticks(const std::vector<Numeric> &ticks, const std::map<std::string
13751377
yticks(ticks, {}, keywords);
13761378
}
13771379

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy