如何访问Gnuplot的(自动)范围值并修改它们以增加一些余量? [英] How to access Gnuplot's (auto)range values and modify them to add some margin?

查看:55
本文介绍了如何访问Gnuplot的(自动)范围值并修改它们以增加一些余量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用标准绘图命令,除了yrange是自动从(例如)275设置为300之外,我还想要什么.

Using the standard plot command, I get, what I want except that the yrange is set automatically from (eg) 275 to 300.

不幸的是,我有几个y坐标为300的数据点,因此它们不可见(由于边界线等).

Unfortunately, I have several data points with y-coordinate 300, such that they are not visible (due to border lines, etc.).

因此,有什么方法可以设置最大值yrange,使其始终是最大数据加上例如. 5个单位?

So, is there any way to set the maximum yrange such that it is always the maximum data plus e.g. 5 units?

使用autoscale,将yrange设置为275:300.将范围明确设置为275:305将适用于一个数据文件,而不适用于其他数据文件.因此,我需要一些通用方法来确定最大数据点并将yrange设置为更大.

Using autoscale, the yrange is set to 275:300. Setting explicitly the range to 275:305 would work for one data file but not for others. So I need some generic method to determine the max-data point and set the yrange larger.

推荐答案

有Gnuplot定义的值GPVAL_Y_MAXGPVAL_DATA_Y_MAX(还有GPVAL_Y_MINGPVAL_DATA_Y_MIN ...).绘制之后,最大值将存储在这些值中.因此,您可以然后按set yrange GPVAL_Y_MAX+(GPVAL_Y_MAX-GPVAL_Y_MIN)*0.05绘制数据.此时,您将第二次绘制数据.这次您就得到了想要的东西.以下是我的代码.

There are Gnuplot defined values GPVAL_Y_MAX and GPVAL_DATA_Y_MAX (also GPVAL_Y_MIN, GPVAL_DATA_Y_MIN ...). After your plot, the maximum value will be stored in these values. So you can plot your data then set yrange GPVAL_Y_MAX+(GPVAL_Y_MAX-GPVAL_Y_MIN)*0.05. At this time you plot you data for the second time. This time you just get what you want. The following is my code.


    reset
    plot "data.dat" u 1:2 #To get the max and min value
    MAX=GPVAL_Y_MAX
    MIN=GPVAL_Y_MIN
    set yrange [MIN-(MAX-MIN)*0.05:MAX+(MAX-MIN)*0.05]
    #Add a fixed value is not a good idea, so I use a relative one
    set term png
    set output "out.png"
    plot "data.dat" u 1:2 w p notitle #This plot will create a file
    #named out.png which is waht you want.

我从本文中学到了这种方法- http://gnuplot-surprising.blogspot.com/2011/09/advanced-background-color-1.html

I learned the method from this article--http://gnuplot-surprising.blogspot.com/2011/09/advanced-background-color-1.html

这篇关于如何访问Gnuplot的(自动)范围值并修改它们以增加一些余量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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