Last active
August 29, 2015 14:25
-
-
Save csullivan/b045de44ad544d7d0044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
py.python_import("pylab","plot"); | |
py.python_import("pylab","savefig"); | |
vector<float> rand; | |
py.__py("import numpy as np; import pylab"); | |
// create an arbitrary list in python and extract it out into c++ land | |
py.__py("x = [float(x) for x in np.random.rand(10)]","x",rand); | |
for(int i=0;i<rand.size();i++){ | |
cout << rand[i] << endl; | |
} | |
// send it back to python as a new list | |
py.functions["plot"](py.VecToList(rand),py.VecToList(rand)); | |
py.__py("pylab.xlim(0.1,0.5)"); | |
// call savefig via c++ function | |
py.functions["savefig"]("./test.pdf"); | |
// or via python | |
py.__py("pylab.savefig('./test.pdf')"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment