gnuplot:如何绘制最大值和/或最小值 [英] Gnuplot: how to plot max and /or min value

查看:435
本文介绍了gnuplot:如何绘制最大值和/或最小值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示最高和/或分钟绘图中图形在适当位置的值会自动显示出来吗?

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

推荐答案

您可以使用stats命令半自动"执行此操作.此命令可以从数据集中提取一些统计值,但需要进行一些重做:

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. 假设数据文件有两列,第一列的x值,第二列的y值,提取最小和最大y值

  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_'

这将为您提供变量Y_minY_max中的最小/最大y值,但没有相应的x值.

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

上一步仅给您获得相应的索引,这要求您再次运行stats才能获得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:

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

  • 这篇关于gnuplot:如何绘制最大值和/或最小值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆