@@ -1022,6 +1022,44 @@ bool scatter(const std::vector<NumericX>& x,
1022
1022
return res;
1023
1023
}
1024
1024
1025
+ template <typename NumericX, typename NumericY, typename NumericColors>
1026
+ bool scatter_colored (const std::vector<NumericX>& x,
1027
+ const std::vector<NumericY>& y,
1028
+ const std::vector<NumericColors>& colors,
1029
+ const double s=1.0 , // The marker size in points**2
1030
+ const std::map<std::string, std::string> & keywords = {})
1031
+ {
1032
+ detail::_interpreter::get ();
1033
+
1034
+ assert (x.size () == y.size ());
1035
+
1036
+ PyObject* xarray = detail::get_array (x);
1037
+ PyObject* yarray = detail::get_array (y);
1038
+ PyObject* colors_array = detail::get_array (colors);
1039
+
1040
+ PyObject* kwargs = PyDict_New ();
1041
+ PyDict_SetItemString (kwargs, " s" , PyLong_FromLong (s));
1042
+ PyDict_SetItemString (kwargs, " c" , colors_array);
1043
+
1044
+ for (const auto & it : keywords)
1045
+ {
1046
+ PyDict_SetItemString (kwargs, it.first .c_str (), PyString_FromString (it.second .c_str ()));
1047
+ }
1048
+
1049
+ PyObject* plot_args = PyTuple_New (2 );
1050
+ PyTuple_SetItem (plot_args, 0 , xarray);
1051
+ PyTuple_SetItem (plot_args, 1 , yarray);
1052
+
1053
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_scatter , plot_args, kwargs);
1054
+
1055
+ Py_DECREF (plot_args);
1056
+ Py_DECREF (kwargs);
1057
+ if (res) Py_DECREF (res);
1058
+
1059
+ return res;
1060
+ }
1061
+
1062
+
1025
1063
template <typename NumericX, typename NumericY, typename NumericZ>
1026
1064
bool scatter (const std::vector<NumericX>& x,
1027
1065
const std::vector<NumericY>& y,
0 commit comments