@@ -37,6 +37,7 @@ struct _interpreter {
3737 PyObject *s_python_function_save;
3838 PyObject *s_python_function_figure;
3939 PyObject *s_python_function_plot;
40+ PyObject *s_python_function_quiver;
4041 PyObject *s_python_function_semilogx;
4142 PyObject *s_python_function_semilogy;
4243 PyObject *s_python_function_loglog;
@@ -139,6 +140,7 @@ struct _interpreter {
139140 s_python_function_pause = PyObject_GetAttrString (pymod, " pause" );
140141 s_python_function_figure = PyObject_GetAttrString (pymod, " figure" );
141142 s_python_function_plot = PyObject_GetAttrString (pymod, " plot" );
143+ s_python_function_quiver = PyObject_GetAttrString (pymod, " quiver" );
142144 s_python_function_semilogx = PyObject_GetAttrString (pymod, " semilogx" );
143145 s_python_function_semilogy = PyObject_GetAttrString (pymod, " semilogy" );
144146 s_python_function_loglog = PyObject_GetAttrString (pymod, " loglog" );
@@ -170,6 +172,7 @@ struct _interpreter {
170172 || !s_python_function_pause
171173 || !s_python_function_figure
172174 || !s_python_function_plot
175+ || !s_python_function_quiver
173176 || !s_python_function_semilogx
174177 || !s_python_function_semilogy
175178 || !s_python_function_loglog
@@ -200,6 +203,7 @@ struct _interpreter {
200203 || !PyFunction_Check (s_python_function_pause)
201204 || !PyFunction_Check (s_python_function_figure)
202205 || !PyFunction_Check (s_python_function_plot)
206+ || !PyFunction_Check (s_python_function_quiver)
203207 || !PyFunction_Check (s_python_function_semilogx)
204208 || !PyFunction_Check (s_python_function_semilogy)
205209 || !PyFunction_Check (s_python_function_loglog)
@@ -481,6 +485,39 @@ bool plot(const std::vector<NumericX>& x, const std::vector<NumericY>& y, const
481485 return res;
482486}
483487
488+ template <typename NumericX, typename NumericY, typename NumericU, typename NumericW>
489+ bool quiver (const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::vector<NumericU>& u, const std::vector<NumericW>& w, const std::map<std::string, std::string>& keywords = {})
490+ {
491+ assert (x.size () == y.size () && x.size () == u.size () && u.size () == w.size ());
492+
493+ PyObject* xarray = get_array (x);
494+ PyObject* yarray = get_array (y);
495+ PyObject* uarray = get_array (u);
496+ PyObject* warray = get_array (w);
497+
498+ PyObject* plot_args = PyTuple_New (4 );
499+ PyTuple_SetItem (plot_args, 0 , xarray);
500+ PyTuple_SetItem (plot_args, 1 , yarray);
501+ PyTuple_SetItem (plot_args, 2 , uarray);
502+ PyTuple_SetItem (plot_args, 3 , warray);
503+
504+ // construct keyword args
505+ PyObject* kwargs = PyDict_New ();
506+ for (std::map<std::string, std::string>::const_iterator it = keywords.begin (); it != keywords.end (); ++it)
507+ {
508+ PyDict_SetItemString (kwargs, it->first .c_str (), PyUnicode_FromString (it->second .c_str ()));
509+ }
510+
511+ PyObject* res = PyObject_Call (
512+ detail::_interpreter::get ().s_python_function_quiver , plot_args, kwargs);
513+
514+ Py_DECREF (plot_args);
515+ if (res)
516+ Py_DECREF (res);
517+
518+ return res;
519+ }
520+
484521template <typename NumericX, typename NumericY>
485522bool stem (const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::string& s = " " )
486523{
0 commit comments