任何人都知道一个matplotlib相当于C或C ++ [英] Anyone knows a matplotlib equivalent in C or C++
问题描述
我一直使用Python项目matplotlib。这是伟大的。
I've been using matplotlib in a Python project. It is great.
我现在有一个C ++项目绘制数据。任何人是否知道在C或C ++中的绘图库?
I have now to plot data in a C++ project. Is anyone aware of a plotting library in C or C++?
请注意,我不能接受GPL许可的库。
Note that I cannot accept GPL licensed libraries.
推荐答案
您可以尝试这样的事情:
You can try something like this:
#include "Python.h"
int main()
{
Py_Initialize();
PyRun_SimpleString("import pylab");
PyRun_SimpleString("pylab.plot(range(5))");
PyRun_SimpleString("pylab.show()");
Py_Exit(0);
return 0;
}
与(我用的是Mac)编译:
compile it with(I am using a Mac):
G ++ -I /库/框架/ Python.framework /版本/ 2.6 /有/ python2.6的/ plot.cpp -lpython2.6
g++ -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/ plot.cpp -lpython2.6
虽然你需要弄清楚如何让您的数据访问matplotlib(尝试写入文件并读)。
Although you need to figure out how to make your data accessible to matplotlib (try writing it to a file and reading it back).
希望帮助,
拉吉
这篇关于任何人都知道一个matplotlib相当于C或C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!