问题
I am new to gnuplot and do not know how to store a variable at the start of gnufile and then use it in rest partof the gnuscript.
The maximum of x-range is equal to the last row in forth column of a file and it varies in every new excersize. On terminal I can print the maximum xrange by tail -n 1 data.dat | awk '{print $4}' which is giving a number say it is 3.83352.
I tried with the code
MAX_XTICK="`tail -n 1 data.dat | awk '{print $4}'`"
and then tried to use it in xrange as
set xrange [ 0 : "$MAX_XTICK"]
but it is giving me error below error plot.gnu", line 64: Can't plot with an empty x range!
I am expecting to use MAX_XTICK variable in xrange as
xrange [ 0 : MAX_XTICK].
回答1:
No need for external scripts. Check help stats and help show variables.
stats "data.dat" u 4
set xrange [0:STATS_max]
In the above example, after performing the stats command, the gnuplot variable STATS_max contains the maximumm of the 4th column.
来源:https://stackoverflow.com/questions/57890274/how-to-store-a-variable-in-gnuplot-and-use-it-in-xrange-and-in-set-arrow