搜索
您的当前位置:首页正文

C++ 结合gnuplot实现数据可视化【1】

来源:知库网

安装:

  • 官网:
    这是个软件,但是打开之后,就是个命令行,类似于Matlab:
    gnuplot

在C++调用:

  • 首先把gnuplot.exe的目录添加到Path环境变量:

    gnuplot.exe的目录
  • 在C++中调用的Demo:

#include <iostream>
using namespace std;

int main()
{
    char*gnuplotPath = "gnuplot.exe";
    FILE* gp = _popen(gnuplotPath,"w");
    if (gp == NULL)
    {
        cout<<("Cannotopen gnuplot!\n")<<endl;;
        return 0;
        //exit(0);
    }
    fprintf(gp,"plot sin(x)\n");
    fprintf(gp,"pause mouse\n");//用户点击后退出
    _pclose(gp);
}
  • 效果图:


    效果图

网上大佬封装的C++库:

ok! 吃饭,看文档去了;

Top