通过gnuplot从数据文件在x轴上打印日期(Print dates on the x

编程入门 行业动态 更新时间:2024-10-27 09:43:20
通过gnuplot从数据文件在x轴上打印日期(Print dates on the x-axis from datafile by gnuplot)

我在这个表示中有数据文件:

07/06/2011 19,06 08/06/2011 31,9099 09/06/2011 31,5 10/06/2011 35 11/06/2011 30 12/06/2011 24,99 13/06/2011 24,5 14/06/2011 20,99 15/06/2011 20 etc. ( I have 1900 records in datafile... )

我正在使用这些操作:

set title "financial data" set grid x y set lmargin 9 set rmargin 2 plot 'data.dat' using 2

我想在x轴日期看到,但我只在x轴上看到一些来自datafile的记录(没有日期)。 我不想在x轴上看到每个日期。 我想在x轴上定期看到大约10个日期:

example 10 dates: x-axis = Jun 2011, Jul 2011, Aug 2011, Sep 2011,...

我怎样才能做到这一点?

I have data file in this represetation:

07/06/2011 19,06 08/06/2011 31,9099 09/06/2011 31,5 10/06/2011 35 11/06/2011 30 12/06/2011 24,99 13/06/2011 24,5 14/06/2011 20,99 15/06/2011 20 etc. ( I have 1900 records in datafile... )

I'm using these operations:

set title "financial data" set grid x y set lmargin 9 set rmargin 2 plot 'data.dat' using 2

I would like to see on the x-axis dates, but I only see on the x-axis some count of records from datafile ( no dates ). I wouldn't like to see each date on x-axis. I want to see about 10 dates regularly on the x-axis:

example 10 dates: x-axis = Jun 2011, Jul 2011, Aug 2011, Sep 2011,...

How can I do this?

最满意答案

您必须将x数据解释为时间。 这是完成的

set xdata time set timefmt '%d/%m/%Y' set xtics 30*24*60*60 set grid plot 'data.dat' using 1:2

零件set xtics 30*24*60*60设置两个主要抽动之间的距离为一个月。 我不知道如何在内部完成,但使用以下示例文件data.dat

01/01/2012 2 01/02/2012 4 01/03/2012 3 01/04/2012 5

结果似乎是正确的:

在此处输入图像描述

根据您的要求,您可能需要更改x轴的格式,例如

set format x '%b %Y'

显示Jun 2011 ...

You must have your x-data interpreted as time. This is done with

set xdata time set timefmt '%d/%m/%Y' set xtics 30*24*60*60 set grid plot 'data.dat' using 1:2

The part set xtics 30*24*60*60 sets the distance between two major tics to be one month. I don't exactly know, how this is done internally, but with the following example file data.dat

01/01/2012 2 01/02/2012 4 01/03/2012 3 01/04/2012 5

the results seems to be correct:

enter image description here

For your requirements you may want to change the format of the x-axis with e.g.

set format x '%b %Y'

to display Jun 2011 ...

更多推荐

本文发布于:2023-07-29 15:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1317623.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   文件   数据   gnuplot   Print

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!