Browse Source

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

pf 5 years ago
parent
commit
107912124d
1 changed files with 4 additions and 1 deletions
  1. 4 1
      matplotlibcpp.h

+ 4 - 1
matplotlibcpp.h

@@ -1834,7 +1834,10 @@ inline void axvspan(double xmin, double xmax, double ymin = 0., double ymax = 1.
     PyObject* kwargs = PyDict_New();
     for(std::map<std::string, std::string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it)
     {
-        PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str()));
+	if (it->first == "linewidth" || it->first == "alpha")
+    	    PyDict_SetItemString(kwargs, it->first.c_str(), PyFloat_FromDouble(std::stod(it->second)));
+  	else
+    	    PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str()));
     }
 
     PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_axvspan, args, kwargs);