@@ -44,6 +44,7 @@ struct _interpreter {
44
44
PyObject *s_python_function_loglog;
45
45
PyObject *s_python_function_fill_between;
46
46
PyObject *s_python_function_hist;
47
+ PyObject *s_python_function_scatter;
47
48
PyObject *s_python_function_subplot;
48
49
PyObject *s_python_function_legend;
49
50
PyObject *s_python_function_xlim;
@@ -151,6 +152,7 @@ struct _interpreter {
151
152
s_python_function_loglog = PyObject_GetAttrString (pymod, " loglog" );
152
153
s_python_function_fill_between = PyObject_GetAttrString (pymod, " fill_between" );
153
154
s_python_function_hist = PyObject_GetAttrString (pymod," hist" );
155
+ s_python_function_scatter = PyObject_GetAttrString (pymod," scatter" );
154
156
s_python_function_subplot = PyObject_GetAttrString (pymod, " subplot" );
155
157
s_python_function_legend = PyObject_GetAttrString (pymod, " legend" );
156
158
s_python_function_ylim = PyObject_GetAttrString (pymod, " ylim" );
@@ -454,6 +456,31 @@ bool hist(const std::vector<Numeric>& y, long bins=10,std::string color="b", dou
454
456
return res;
455
457
}
456
458
459
+ template <typename NumericX, typename NumericY>
460
+ bool scatter (const std::vector<NumericX>& x,
461
+ const std::vector<NumericY>& y,
462
+ const double s=1.0 ) // The marker size in points**2
463
+ {
464
+ assert (x.size () == y.size ());
465
+
466
+ PyObject* xarray = get_array (x);
467
+ PyObject* yarray = get_array (y);
468
+
469
+ PyObject* kwargs = PyDict_New ();
470
+ PyDict_SetItemString (kwargs, " s" , PyLong_FromLong (s));
471
+
472
+ PyObject* plot_args = PyTuple_New (2 );
473
+ PyTuple_SetItem (plot_args, 0 , xarray);
474
+ PyTuple_SetItem (plot_args, 1 , yarray);
475
+
476
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_scatter , plot_args, kwargs);
477
+
478
+ Py_DECREF (plot_args);
479
+ if (res) Py_DECREF (res);
480
+
481
+ return res;
482
+ }
483
+
457
484
template < typename Numeric>
458
485
bool named_hist (std::string label,const std::vector<Numeric>& y, long bins=10 , std::string color=" b" , double alpha=1.0 )
459
486
{
0 commit comments