@@ -37,6 +37,7 @@ struct _interpreter {
37
37
PyObject *s_python_function_save;
38
38
PyObject *s_python_function_figure;
39
39
PyObject *s_python_function_plot;
40
+ PyObject *s_python_function_quiver;
40
41
PyObject *s_python_function_semilogx;
41
42
PyObject *s_python_function_semilogy;
42
43
PyObject *s_python_function_loglog;
@@ -139,6 +140,7 @@ struct _interpreter {
139
140
s_python_function_pause = PyObject_GetAttrString (pymod, " pause" );
140
141
s_python_function_figure = PyObject_GetAttrString (pymod, " figure" );
141
142
s_python_function_plot = PyObject_GetAttrString (pymod, " plot" );
143
+ s_python_function_quiver = PyObject_GetAttrString (pymod, " quiver" );
142
144
s_python_function_semilogx = PyObject_GetAttrString (pymod, " semilogx" );
143
145
s_python_function_semilogy = PyObject_GetAttrString (pymod, " semilogy" );
144
146
s_python_function_loglog = PyObject_GetAttrString (pymod, " loglog" );
@@ -170,6 +172,7 @@ struct _interpreter {
170
172
|| !s_python_function_pause
171
173
|| !s_python_function_figure
172
174
|| !s_python_function_plot
175
+ || !s_python_function_quiver
173
176
|| !s_python_function_semilogx
174
177
|| !s_python_function_semilogy
175
178
|| !s_python_function_loglog
@@ -200,6 +203,7 @@ struct _interpreter {
200
203
|| !PyFunction_Check (s_python_function_pause)
201
204
|| !PyFunction_Check (s_python_function_figure)
202
205
|| !PyFunction_Check (s_python_function_plot)
206
+ || !PyFunction_Check (s_python_function_quiver)
203
207
|| !PyFunction_Check (s_python_function_semilogx)
204
208
|| !PyFunction_Check (s_python_function_semilogy)
205
209
|| !PyFunction_Check (s_python_function_loglog)
@@ -481,6 +485,39 @@ bool plot(const std::vector<NumericX>& x, const std::vector<NumericY>& y, const
481
485
return res;
482
486
}
483
487
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
+
484
521
template <typename NumericX, typename NumericY>
485
522
bool stem (const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::string& s = " " )
486
523
{
0 commit comments