@@ -75,6 +75,7 @@ struct _interpreter {
75
75
PyObject *s_python_function_ylim;
76
76
PyObject *s_python_function_title;
77
77
PyObject *s_python_function_axis;
78
+ PyObject *s_python_function_axhline;
78
79
PyObject *s_python_function_axvline;
79
80
PyObject *s_python_function_axvspan;
80
81
PyObject *s_python_function_xlabel;
@@ -247,6 +248,7 @@ struct _interpreter {
247
248
s_python_function_ylim = safe_import (pymod, " ylim" );
248
249
s_python_function_title = safe_import (pymod, " title" );
249
250
s_python_function_axis = safe_import (pymod, " axis" );
251
+ s_python_function_axhline = safe_import (pymod, " axhline" );
250
252
s_python_function_axvline = safe_import (pymod, " axvline" );
251
253
s_python_function_axvspan = safe_import (pymod, " axvspan" );
252
254
s_python_function_xlabel = safe_import (pymod, " xlabel" );
@@ -2238,6 +2240,31 @@ inline void axis(const std::string &axisstr)
2238
2240
Py_DECREF (res);
2239
2241
}
2240
2242
2243
+ inline void axhline (double y, double xmin = 0 ., double xmax = 1 ., const std::map<std::string, std::string>& keywords = std::map<std::string, std::string>())
2244
+ {
2245
+ detail::_interpreter::get ();
2246
+
2247
+ // construct positional args
2248
+ PyObject* args = PyTuple_New (3 );
2249
+ PyTuple_SetItem (args, 0 , PyFloat_FromDouble (y));
2250
+ PyTuple_SetItem (args, 1 , PyFloat_FromDouble (xmin));
2251
+ PyTuple_SetItem (args, 2 , PyFloat_FromDouble (xmax));
2252
+
2253
+ // construct keyword args
2254
+ PyObject* kwargs = PyDict_New ();
2255
+ for (std::map<std::string, std::string>::const_iterator it = keywords.begin (); it != keywords.end (); ++it)
2256
+ {
2257
+ PyDict_SetItemString (kwargs, it->first .c_str (), PyString_FromString (it->second .c_str ()));
2258
+ }
2259
+
2260
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_axhline , args, kwargs);
2261
+
2262
+ Py_DECREF (args);
2263
+ Py_DECREF (kwargs);
2264
+
2265
+ if (res) Py_DECREF (res);
2266
+ }
2267
+
2241
2268
inline void axvline (double x, double ymin = 0 ., double ymax = 1 ., const std::map<std::string, std::string>& keywords = std::map<std::string, std::string>())
2242
2269
{
2243
2270
detail::_interpreter::get ();
0 commit comments