Gnuplot: how to plot max and /or min value [closed]

倾然丶 夕夏残阳落幕 提交于 2019-11-27 03:38:05

问题


How can I show the max. and/or the min. value(s) of of a graph in a plot at their appropriate position automatically?


回答1:


You can do this "semi-automatically" using the stats command. This command can extract some statistical values from a data set, but requires some reworking:

  1. Extract the minimum and maximum y-values, assuming that your data file has two columns, the x-value in the first, the y-values in the second column

    stats 'file.dat' using 2 nooutput name 'Y_'
    

    This gives you the min/max y-values in the variables Y_min and Y_max, but not the corresponding x-value.

  2. The previous step gives you only get the respective indices, which requires you to run stats again in order to get the x-values:

     stats 'file.dat' using 1 every ::Y_index_min::Y_index_min nooutput
     X_min = STATS_min
     stats 'file.dat' using 1 every ::Y_index_max::Y_index_max nooutput
     X_max = STATS_max
    
  3. Set labels and/or points at the respective coordinates

    set label 1 sprintf("%.2f", Y_min) center at first X_min,Y_min point pt 7 ps 1 offset 0,-1.5
    set label 2 sprintf("%.2f", Y_max) center at first X_max,Y_max point pt 7 ps 1 offset 0,1.5
    ...
    plot ...
    


来源:https://stackoverflow.com/questions/30130639/gnuplot-how-to-plot-max-and-or-min-value

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