Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Colormap to scatter_colored #365

Open
Open

Description

I've added a new version of the scatter_colored function to manage the colormap. It would be great if I could push this!

template<typename NumericX, typename NumericY, typename NumericColors>
 bool scatter_colored(const std::vector<NumericX>& x,
 const std::vector<NumericY>& y,
 const std::vector<NumericColors>& colors,
 const double s=1.0, // The marker size in points**2
 const std::string& cmap="hsv",
 const std::map<std::string, std::string> & keywords = {})
 {
 detail::_interpreter::get();
 assert(x.size() == y.size());
 PyObject* xarray = detail::get_array(x);
 PyObject* yarray = detail::get_array(y);
 PyObject* colors_array = detail::get_array(colors);
 PyObject* cm = PyString_FromString(cmap.c_str());
 PyObject* kwargs = PyDict_New();
 PyDict_SetItemString(kwargs, "s", PyLong_FromLong(s));
 PyDict_SetItemString(kwargs, "c", colors_array);
 PyDict_SetItemString(kwargs, "cmap", cm);
 for (const auto& it : keywords)
 {
 PyDict_SetItemString(kwargs, it.first.c_str(), PyString_FromString(it.second.c_str()));
 }
 PyObject* plot_args = PyTuple_New(2);
 PyTuple_SetItem(plot_args, 0, xarray);
 PyTuple_SetItem(plot_args, 1, yarray);
 PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_scatter, plot_args, kwargs);
 Py_DECREF(plot_args);
 Py_DECREF(kwargs);
 if(res) Py_DECREF(res);
 return res;
 }
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /