i use matplotlib from c++ for (debug-)plotting. I want to plot several plots in the same graph. So far i have
template<typename NumericX, typename NumericY>
bool plot(const NumericX const* x, const NumericY const* y, std::size_t size, const std::string& s = "")
{
PyObject* xlist = PyList_New(size);
PyObject* ylist = PyList_New(size);
PyObject* pystring = PyUnicode_FromString(s.c_str());
for(size_t i = 0; i < size; ++i) {
PyList_SetItem(xlist, i, PyFloat_FromDouble(x[i]));
PyList_SetItem(ylist, i, PyFloat_FromDouble(y[i]));
}
PyObject* plot_args = PyTuple_New(3);
PyTuple_SetItem(plot_args, 0, xlist);
PyTuple_SetItem(plot_args, 1, ylist);
PyTuple_SetItem(plot_args, 2, pystring);
PyObject* pymod = PyImport_Import(pyplotname);
PyObject* s_python_function_plot = PyObject_GetAttrString(pymod, "plot");
PyObject* res = PyObject_CallObject(s_python_function_plot, plot_args);
Py_DECREF(xlist);
Py_DECREF(ylist);
Py_DECREF(plot_args);
if(res) Py_DECREF(res);
return res;
}
but calling
plot(x_0,_y_0, size_0);
plot(x_1,_y_1, size_1);
show(); // just calling matplotlib.show
shows only the first plot. What can i do, to get all the plots?