@@ -73,6 +73,7 @@ struct _interpreter {
7373 PyObject *s_python_function_title;
7474 PyObject *s_python_function_axis;
7575 PyObject *s_python_function_axvline;
76+ PyObject *s_python_function_axvspan;
7677 PyObject *s_python_function_xlabel;
7778 PyObject *s_python_function_ylabel;
7879 PyObject *s_python_function_gca;
@@ -208,6 +209,7 @@ struct _interpreter {
208209 s_python_function_title = safe_import (pymod, " title" );
209210 s_python_function_axis = safe_import (pymod, " axis" );
210211 s_python_function_axvline = safe_import (pymod, " axvline" );
212+ s_python_function_axvspan = safe_import (pymod, " axvspan" );
211213 s_python_function_xlabel = safe_import (pymod, " xlabel" );
212214 s_python_function_ylabel = safe_import (pymod, " ylabel" );
213215 s_python_function_gca = safe_import (pymod, " gca" );
@@ -1819,6 +1821,29 @@ inline void axvline(double x, double ymin = 0., double ymax = 1., const std::map
18191821 if (res) Py_DECREF (res);
18201822}
18211823
1824+ inline void axvspan (double xmin, double xmax, double ymin = 0 ., double ymax = 1 ., const std::map<std::string, std::string>& keywords = std::map<std::string, std::string>())
1825+ {
1826+ // construct positional args
1827+ PyObject* args = PyTuple_New (4 );
1828+ PyTuple_SetItem (args, 0 , PyFloat_FromDouble (xmin));
1829+ PyTuple_SetItem (args, 1 , PyFloat_FromDouble (xmax));
1830+ PyTuple_SetItem (args, 2 , PyFloat_FromDouble (ymin));
1831+ PyTuple_SetItem (args, 3 , PyFloat_FromDouble (ymax));
1832+
1833+ // construct keyword args
1834+ PyObject* kwargs = PyDict_New ();
1835+ for (std::map<std::string, std::string>::const_iterator it = keywords.begin (); it != keywords.end (); ++it)
1836+ {
1837+ PyDict_SetItemString (kwargs, it->first .c_str (), PyString_FromString (it->second .c_str ()));
1838+ }
1839+
1840+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_axvspan , args, kwargs);
1841+ Py_DECREF (args);
1842+ Py_DECREF (kwargs);
1843+
1844+ if (res) Py_DECREF (res);
1845+ }
1846+
18221847inline void xlabel (const std::string &str, const std::map<std::string, std::string> &keywords = {})
18231848{
18241849 detail::_interpreter::get ();
0 commit comments