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 个解决方案
#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:
您可以使用stats命令“半自动”执行此操作。此命令可以从数据集中提取一些统计值,但需要进行一些重写:
-
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
提取最小和最大y值,假设您的数据文件有两列,第一列中的x值,第二列中的y值
stats 'file.dat' using 2 nooutput name 'Y_'
This gives you the min/max y-values in the variables
Y_min
andY_max
, but not the corresponding x-value.这为您提供变量Y_min和Y_max中的最小/最大y值,但不是相应的x值。
-
The previous step gives you only get the respective indices, which requires you to run
stats
again in order to get the x-values:上一步只允许您获取相应的索引,这需要您再次运行统计信息以获取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
-
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 ...
#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:
您可以使用stats命令“半自动”执行此操作。此命令可以从数据集中提取一些统计值,但需要进行一些重写:
-
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
提取最小和最大y值,假设您的数据文件有两列,第一列中的x值,第二列中的y值
stats 'file.dat' using 2 nooutput name 'Y_'
This gives you the min/max y-values in the variables
Y_min
andY_max
, but not the corresponding x-value.这为您提供变量Y_min和Y_max中的最小/最大y值,但不是相应的x值。
-
The previous step gives you only get the respective indices, which requires you to run
stats
again in order to get the x-values:上一步只允许您获取相应的索引,这需要您再次运行统计信息以获取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
-
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 ...