以下是我用来写入数据(x和y坐标)到文件中的代码。
void display(){
fstream out;
outfile.open("Co_ordinates.txt",fstream::out | fstream::trunc);
outfile.precision(6);
for(int i=0;i<3000; i++){
outfile<<fixed<<x[i]<<" "<<fixed<<y[i]<<endl;
}
out.close();
}
我想使用上述文件"Co_ordinates.txt"中的x和y坐标绘制图表,我已经添加了gnuplot实用程序"gnuplot_i.hpp",其来源于https://code.google.com/p/gnuplot-cpp/source/browse/trunk/gnuplot_i.hpp。
我已使用gnuplot_i.hpp中定义的以下函数:
/// plot x,y pairs: x y
/// from file
Gnuplot& plotfile_xy(const std::string &filename,
const unsigned int column_x = 1,
const unsigned int column_y = 2,
const std::string &title = "");
我已经添加了以下代码来绘制图表
const string s="Co_ordinates.txt";
Gnuplot& plotfile_xy(&s,1,2,'Grid');
但是出现以下错误:
error: 表达式列表在初始化器中被视为复合表达式[-fpermissive]| error: 非const引用类型的无效初始化‘Gnuplot&’从类型为‘int’的右值|
我已经尝试了上述代码的几种形式,但是仍然出现错误。 请提供一些解决方案..
Gnuplot& plotfile_xy(&s,1,2,'Grid');
这行代码,编译器看作是函数声明而不是调用。 - 1.618