From: <am...@gm...> - 2014-02-15 06:48:19
|
Found out the solution set pm3d map ;sp 'dataBinary.dat' binary record=(100,-1) format='%f' u 1:2:3 w pm3d here record=(100,-1) will tell gnuplot that each isoline contains 100 data points and -1 will tell that it has to be read upto end of file. So we dont need a blank line in binary files. Cheers Amol From: am...@gm...<am...@gm...> To: <gnu...@li...> Sent: Saturday, February 15, 2014 Subject: [Gnuplot-info] Binary Plot by C++ Dear All, Please have a look at the C++ code to generate a binary data which can be plotted by the gnuplot. I am having trouble in introducing a blank line in the binary file so that gnuplot can plot it as pm3d map. Thank you, ////////////////////////////////////////////////////////////////////////////////////////////// /* A 2D binary data generated by the code can be plotted by gnuplot> p 'dataBinary.dat' binary format='%f%f%f' u 1:3 w l which is equivalent to plot the ASCII data as gnuplot> p 'dataAscii.dat' u 1:3 w l The pm3d map plot can be plotted for ASCII data as follows, provided one should have a blank line after each set of data. Blank line should be introduced after the completion of inner 'for loop' in the following code. gnuplot> set pm3d map; gnuplot> sp 'dataAscii.dat' u 1:2:3 w pm3d ;How one can plot the pm3d data in binary file format. The only thing missing is the introduction of blank line in the binary data which should be understood by the gnuplot. gnuplot> set pm3d map; gnuplot> sp 'dataBinary.dat' binary format='%f%f%f' u 1:2:3 w pm3d; The above command does not plot a pm3d from binary data as there is a blank line missing in it. */ #include <iostream> #include <cmath> #include <cstdlib> #include <fstream> #include <cstdio> #include <iomanip> using namespace std ;struct Data { float x,y,z ;} ;int main() { ofstream outf("dataBinary.dat",ios::binary) ; //ofstream outf("dataAscii.dat",ios::out) ; Data myData[100] ; for(int i=0;i<100;i++) { for(int j=0;j<100;j++) { myData[j].x = i ; myData[j].y = j ; myData[j].z = sqrt(i+j) ; // writing ASCII data //outf << endl << myData[j].x << setw(15) << myData[j].y << setw(15) << myData[j].z ; } //outf << endl ; // for ascii data to be plotted as pm3d by gnuplot // writing binary data outf.write((char *)(&myData),sizeof(myData)); } outf.close() ; cout << endl ; return 0 ;} ////////////////////////////////////////////////////////////////////////////////////////////// ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk _______________________________________________ gnuplot-info mailing list gnu...@li... Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info |