MCPcopy Create free account
hub / github.com/accellera-official/systemc / plot

Function plot

examples/sysc/async_suspend/matplotlibcpp.h:327–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325
326template<typename Numeric>
327bool plot(const std::vector<Numeric> &x, const std::vector<Numeric> &y, const std::map<std::string, std::string>& keywords)
328{
329 assert(x.size() == y.size());
330
331 // using numpy arrays
332 PyObject* xarray = get_array(x);
333 PyObject* yarray = get_array(y);
334
335 // construct positional args
336 PyObject* args = PyTuple_New(2);
337 PyTuple_SetItem(args, 0, xarray);
338 PyTuple_SetItem(args, 1, yarray);
339
340 // construct keyword args
341 PyObject* kwargs = PyDict_New();
342 for(std::map<std::string, std::string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it)
343 {
344 PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str()));
345 }
346
347 PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_plot, args, kwargs);
348
349 Py_DECREF(args);
350 Py_DECREF(kwargs);
351 if(res) Py_DECREF(res);
352
353 return res;
354}
355
356template <typename Numeric>
357void plot_surface(const std::vector<::std::vector<Numeric>> &x,

Callers 1

matplotMethod · 0.85

Calls 6

get_arrayFunction · 0.85
c_strMethod · 0.80
atMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected