How to store a variable in gnuplot and use it in xrange and in set arrow

安稳与你 提交于 2019-12-13 06:10:01

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!