Below is the code I used to write the data (x and y coordinates) to a file.
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(); }
I want to plot using the x and y coordinates from the above file "Co_ordinates.txt". I added the gnuplot utility "gnuplot_i.hpp" from https://code.google.com/p/gnuplot-cpp/source/browse/trunk/gnuplot_i.hpp .
I used the following function defined in gnuplot_i.hpp
/// plot x,y pairs: xy /// 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 = "");
I added the following code to plot
const string s="Co_ordinates.txt"; Gnuplot& plotfile_xy(&s,1,2,'Grid');
But getting the following errors
error: expression list processed as a compound expression in the initializer [-fpermissive] | error: invalid initialization of non-constant reference of type 'Gnuplot & from rvalue of type' int |
I tried the above code in several forms, but got errors. Please suggest some solutions.
c ++ gnuplot
user3851761
source share