Skip to content

Commit 1079121

Browse files
pflava
authored andcommitted
a few of the parameters are floats. This is a quick hack to get a couple of them to work. In the future matplotlibcpp should use map<string,any> instead of map<string,string> for kwargs. That should be a separate PR
1 parent 480af0f commit 1079121

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

matplotlibcpp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,10 @@ inline void axvspan(double xmin, double xmax, double ymin = 0., double ymax = 1.
18341834
PyObject* kwargs = PyDict_New();
18351835
for(std::map<std::string, std::string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it)
18361836
{
1837-
PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str()));
1837+
if (it->first == "linewidth" || it->first == "alpha")
1838+
PyDict_SetItemString(kwargs, it->first.c_str(), PyFloat_FromDouble(std::stod(it->second)));
1839+
else
1840+
PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str()));
18381841
}
18391842

18401843
PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_axvspan, args, kwargs);

0 commit comments

Comments
 (0)