Saturday 15 August 2015

python - Embedding matplotlib in C -


I have a double pointer in C, and I want to plot it from seed with matplotlib. I do not understand how to do that with Python / C API can someone give me a simple example? A simple code can be something similar:

  #include & lt; Python.h & gt; #define N 10 int main (zero) {double * a_c; PyObject * a_python; Int i; A_c = (double *) molk (size (double) * N); For (i = 0; i & lt; N; i ++) a_c [i] = (double) i //...a_python = some_function (a_c) .... / * Py_Initialize (); PyRun_SimpleString ("Import as matplotlib.pyplot plt"); PyRun_SimpleString ("plt.plot (a_python)"); ?? PyRun_SimpleString ("plt.show ()"); Py_Exit (0); * / Return 0; }   

Thanks advance!

You can use Cython to call the C code from the Python script, if you have a Python Master Script Want to write that calls your C code and is related to plotting.

No comments:

Post a Comment