Gnuplot:如何绘制最大值和/或最小值

Gnuplot: how to plot max and /or min value

我怎样才能显示最大值。 and/or 分钟。绘图中图表的值自动位于适当的位置?

您可以使用 stats 命令执行此操作 "semi-automatically"。此命令可以从数据集中提取一些统计值,但需要一些修改:

  1. 提取最小和最大 y 值,假设您的数据文件有两列,第一列中的 x 值,第二列中的 y 值

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

    这为您提供变量 Y_minY_max 中的 min/max y 值,但不是相应的 x 值。

  2. 上一步只让你得到各自的索引,这需要你再次运行 stats才能得到x值:

     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. 在各自的坐标and/or设置标签and/or点

    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 ...