【问题标题】:Gnuplot: how to plot max and /or min value [closed]Gnuplot:如何绘制最大值和/或最小值
【发布时间】:2015-07-19 18:31:07
【问题描述】:

如何显示最大值。和/或分钟。绘图中的图形的值是否自动在其适当位置?

【问题讨论】:

    标签: max gnuplot minimum


    【解决方案1】:

    您可以使用stats 命令“半自动”执行此操作。此命令可以从数据集中提取一些统计值,但需要进行一些修改:

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

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

      这将为您提供变量 Y_minY_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. 在相应坐标处设置标签和/或点

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

    【讨论】:

    • 看起来不错。如果 x 系列是时间数据,则不起作用。 "统计命令在时间数据模式下不可用"
    • @gaoithe 是的,我知道。对于时间数据,您必须执行 stats 'file.dat' using 2 nooutput name 'Y_'; set timefmt '%H:%M:%S'; stats 'file.dat' using (timecolumn(1)) every ::Y_index_min::Y_index_min noutput; ...; set xdata time; plot ... 之类的操作
    • 好的,谢谢。我发现您的回答在这里很有帮助:stackoverflow.com/questions/17977086/… 我的解决方案更复杂,因为使用空格分隔文件。日期/时间在引号内,该字符串内也有空格。必须转换为 .csv。 stats 命令非常有用!
    • @gaoithe 你不需要 csv,``timecolumn` 可以正确处理空格分隔的日期/时间字段。
    • gnuplot 5.2:Stats 命令在极坐标模式下不可用
    猜你喜欢
    • 2016-10-22
    • 1970-01-01
    • 2020-02-01
    • 2014-03-24
    • 2020-06-20
    • 1970-01-01
    • 2017-06-22
    相关资源
    最近更新 更多