@@ -44,6 +44,7 @@ struct _interpreter {
4444 PyObject *s_python_function_loglog;
4545 PyObject *s_python_function_fill_between;
4646 PyObject *s_python_function_hist;
47+ PyObject *s_python_function_scatter;
4748 PyObject *s_python_function_subplot;
4849 PyObject *s_python_function_legend;
4950 PyObject *s_python_function_xlim;
@@ -151,6 +152,7 @@ struct _interpreter {
151152 s_python_function_loglog = PyObject_GetAttrString (pymod, " loglog" );
152153 s_python_function_fill_between = PyObject_GetAttrString (pymod, " fill_between" );
153154 s_python_function_hist = PyObject_GetAttrString (pymod," hist" );
155+ s_python_function_scatter = PyObject_GetAttrString (pymod," scatter" );
154156 s_python_function_subplot = PyObject_GetAttrString (pymod, " subplot" );
155157 s_python_function_legend = PyObject_GetAttrString (pymod, " legend" );
156158 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
454456 return res;
455457}
456458
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+
457484template < typename Numeric>
458485bool named_hist (std::string label,const std::vector<Numeric>& y, long bins=10 , std::string color=" b" , double alpha=1.0 )
459486{
0 commit comments