Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading external data files in gnuplot

Well, this is a continuation of my previous question. As, I mentioned, the data files are produced from a Fortran code. All the data files contain two columns of data. In the Fortran code I use the FORMAT (2(1X,D22.16)). So, the output files look like

-.4515533388641104D-01 -.6842652196656712D+01
-.1381692033642749D+00 0.6762844180244199D+01
-.5741668880663318D-01 -.7891086299010933D+01
-.1051164522902431D+00 0.7758389636011907D+01
-.7574000988697732D-01 -.8180315630079706D+01
-.7939204753736680D-01 0.8167097825331970D+01
-.1003250672387262D+00 -.7865995561517515D+01
-.6006135667296913D-01 0.7987393828927278D+01
 ..................... ......................

This is only a small sample portion of one data file. In order to plot this data file I use

plot "data001.out" u 1:2 w d lc rgb 'black'

However, gnuplot fails to read the data correctly and produced this plot

enter image description here

The correct plot, using Mathematica program, is this

enter image description here

I noticed, that if I change the FORMAT to (2(1X,F22.16)) (in decimal form) everything is OK. Why gnuplot cannot read data in exponential form? Is there a way to tell the program how to read this type of data?

like image 558
Vaggelis_Z Avatar asked May 21 '26 03:05

Vaggelis_Z


1 Answers

From gnuplot 4.6 manual:

"Data may be written in exponential format with the exponent preceded by the letter e or E. The fortran exponential specifiers d, D, q, and Q may also be used if the command set datafile fortran is in effect."

So you should put set datafile fortran before plot.

Hope it helps!

like image 144
lev.tuby Avatar answered May 25 '26 11:05

lev.tuby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!