Home > Mobile >  Gnuplot animation, how to print text from data file to graph
Gnuplot animation, how to print text from data file to graph

Time:12-02

I want to plot columns 1 and 2, and print column 3 from a data file, however I cannot find how to directly read from the data file into x or into an array x(n), basically the operation is this:

do for[j=0:n:1]{
    unset label
    x = #row j, column 3 of 'file-name.dat'
    set label x at 2000, 4000 ...
    plot 'file-name.dat' u 1:2 ....
}

CodePudding user response:

Your question is not very clear. Please always provide example data. How does your data look like and what exactly do you want to plot? Do you want to plot the complete column 1 and 2 or just the row j? Check the following example and check help every and help labels.

Code:

### plotting labels for animation
reset session

set term gif animate delay 50
set output "SO70101046.gif"

$Data <<EOD
0   0   Time0
1   1   Time1
2   2   Time2
3   3   Time3
4   4   Time4
5   5   Time5
EOD

stats $Data nooutput   # get the number of rows
N = STATS_records

set xrange[-1:6]
set yrange[-1:6]

do for [j=0:N-1] {
    plot $Data u 1:2 every ::j::j w lp pt 7 title "Data", \
         ''    u (0):(5):3 every ::j::j w labels notitle
}
set output
### end of code

Result:

enter image description here

  • Related