我如何在gnuplot的从Y数据自动减去最低值一个阴谋? [英] How do I make a plot in gnuplot with the lowest value automatically subtracted from the y data?

查看:347
本文介绍了我如何在gnuplot的从Y数据自动减去最低值一个阴谋?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我策划了一大批在gnuplot的文件的创建时间,看看他们是否在时间上线创建(他们不是)。

I am plotting the creation times of a large batch of files in gnuplot to see if they are created linearly in time (they are not).

下面是我的code:

#!/bin/bash

stat -c %Y img2/*png > timedata

echo "set terminal postscript enhanced colour
set output 'file_creation_time.eps'
plot 'timedata'" | gnuplot

我的问题是,在y的数据是在几秒钟内的创建时间以来的unix开始时间,所以情节只是有1.333 ... E +在y轴09。我想有缩放到零,这样的相对创建时间是可读的第一个文件的创建时间。

The problem I have is that the y data are the creation time in seconds since unix start time, so the plot just has 1.333...e+09 on the y-axis. I would like to have the creation time of the first file scaled to zero so that the relative creation times are readable.

我遇到了一些数据绘制上下文这个问题,所以我希望能够在gnuplot的做到这一点,而不是诉诸AWK或者一些实用程序preprocess的数据。

I encounter this problem in a number of data-plotting contexts, so I would like to be able to do this within gnuplot rather than resorting to awk or some utility to preprocess the data.

我知道在第一时间将是最小的,因为这些文件被连续命名​​的,所以是有访问的第一个元素在文件中的方式,类似

I know the first time will be the smallest since the files are named serially, so is there a way to access the first element in a file, something like

`plot 'data' using ($1-$1[firstelement])`

推荐答案

我觉得你可以做这样的事情......(以下是未经测试,但我认为它应该工作...)。基本上,你必须绘制文件两次 - 第一次通过gnuplot的回升有关数据统计。第二次通过,你用你的第一个贯通发现什么阴谋你真正想要的东西。

I think you can do something like that...(the following is untested, but I think it should work...). Basically, you have to plot the file twice -- the first time through gnuplot picks up statistics about the dataset. The second time through, you use what you found on the first run-through to plot what you actually want.

set terminal unknown
plot 'datafile' using 1:2
set terminal post enh eps color
set output 'myfile.eps'
YMIN=GPVAL_Y_MIN
plot '' u 1:($2-YMIN)

如果您已GNUPLOT 4.6,你可以使用统计命令同样的事情。
http://www.gnuplot.info/demo/stats.html

If you have gnuplot 4.6, you can do the same thing with the stats command. http://www.gnuplot.info/demo/stats.html

修改看来你要的第一点提供的偏移(不好意思,看错题)...

EDIT It appears you want the first point to provide the offset (sorry, misread the question)...

如果你想第一点提供的偏移量,你可以像做(再次,未经测试 - 需要gnuplot的> = 4.3):

If you want the first point to provide the offset, you may be able to do something like (again, untested -- requires gnuplot >= 4.3):

first=0;
offset=0;
func(x)=(offset=(first==0)?x:offset,first=1,x-offset)
plot 'datafile' using (func($1))

这篇关于我如何在gnuplot的从Y数据自动减去最低值一个阴谋?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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