@@ -1217,6 +1217,53 @@ bool boxplot(const std::vector<Numeric>& data,
1217
1217
return res;
1218
1218
}
1219
1219
1220
+ template <typename Numeric>
1221
+ bool bar (const std::vector<Numeric> & x,
1222
+ const std::vector<Numeric> & y,
1223
+ const std::vector<Numeric> & bottom,
1224
+ double width = 0.8 ,
1225
+ std::string ec = " black" ,
1226
+ std::string ls = " -" ,
1227
+ double lw = 1.0 ,
1228
+ const std::map<std::string, std::string> & keywords = {})
1229
+ {
1230
+ detail::_interpreter::get ();
1231
+
1232
+ PyObject * xarray = detail::get_array (x);
1233
+ PyObject * yarray = detail::get_array (y);
1234
+ PyObject* obj_width = PyFloat_FromDouble (width);
1235
+ PyObject * bottomarray = detail::get_array (bottom);
1236
+
1237
+ PyObject * kwargs = PyDict_New ();
1238
+
1239
+ PyDict_SetItemString (kwargs, " ec" , PyString_FromString (ec.c_str ()));
1240
+ PyDict_SetItemString (kwargs, " ls" , PyString_FromString (ls.c_str ()));
1241
+ PyDict_SetItemString (kwargs, " lw" , PyFloat_FromDouble (lw));
1242
+
1243
+ for (std::map<std::string, std::string>::const_iterator it =
1244
+ keywords.begin ();
1245
+ it != keywords.end ();
1246
+ ++it) {
1247
+ PyDict_SetItemString (
1248
+ kwargs, it->first .c_str (), PyUnicode_FromString (it->second .c_str ()));
1249
+ }
1250
+
1251
+ PyObject * plot_args = PyTuple_New (4 );
1252
+ PyTuple_SetItem (plot_args, 0 , xarray);
1253
+ PyTuple_SetItem (plot_args, 1 , yarray);
1254
+ PyTuple_SetItem (plot_args, 2 , obj_width);
1255
+ PyTuple_SetItem (plot_args, 3 , bottomarray);
1256
+
1257
+ PyObject * res = PyObject_Call (
1258
+ detail::_interpreter::get ().s_python_function_bar , plot_args, kwargs);
1259
+
1260
+ Py_DECREF (plot_args);
1261
+ Py_DECREF (kwargs);
<
618A
/code>
1262
+ if (res) Py_DECREF (res);
1263
+
1264
+ return res;
1265
+ }
1266
+
1220
1267
template <typename Numeric>
1221
1268
bool bar (const std::vector<Numeric> & x,
1222
1269
const std::vector<Numeric> & y,
0 commit comments