| 325 | |
| 326 | template<typename Numeric> |
| 327 | bool plot(const std::vector<Numeric> &x, const std::vector<Numeric> &y, const std::map<std::string, std::string>& keywords) |
| 328 | { |
| 329 | assert(x.size() == y.size()); |
| 330 | |
| 331 | // using numpy arrays |
| 332 | PyObject* xarray = get_array(x); |
| 333 | PyObject* yarray = get_array(y); |
| 334 | |
| 335 | // construct positional args |
| 336 | PyObject* args = PyTuple_New(2); |
| 337 | PyTuple_SetItem(args, 0, xarray); |
| 338 | PyTuple_SetItem(args, 1, yarray); |
| 339 | |
| 340 | // construct keyword args |
| 341 | PyObject* kwargs = PyDict_New(); |
| 342 | for(std::map<std::string, std::string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it) |
| 343 | { |
| 344 | PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str())); |
| 345 | } |
| 346 | |
| 347 | PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_plot, args, kwargs); |
| 348 | |
| 349 | Py_DECREF(args); |
| 350 | Py_DECREF(kwargs); |
| 351 | if(res) Py_DECREF(res); |
| 352 | |
| 353 | return res; |
| 354 | } |
| 355 | |
| 356 | template <typename Numeric> |
| 357 | void plot_surface(const std::vector<::std::vector<Numeric>> &x, |