2015-05-08 91 views

回答

3

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

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

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

    这给你在变量最小/最大y值Y_minY_max,但不是对应的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 ... 
    
+0

看起来不错。如果x系列是时间数据,则不起作用。 “统计命令在timedata模式下不可用” – gaoithe

+1

@gaoithe是的,我知道。对于时间数据,您必须使用2个nooutput名称'Y_'执行类似'stats'file.dat'的操作;设置timefmt'%H:%M:%S'; stats'file.dat'using(timecolumn(1))every :: Y_index_min :: Y_index_min noutput; ...;设置xdata时间;剧情......' – Christoph

+0

是的,谢谢。我发现你的答案在这里有帮助:http://stackoverflow.com/questions/17977086/plotting-only-the-common-data-in-a-data-series-with-gnuplot我的解决方案更复杂,因为正在使用whitespace-字段分隔的文件。在日期/时间里面带有空格的引号。必须转换为.csv。 stats命令非常有用! – gaoithe