通过gnuplot从数据文件打印x轴上的日期

时间:2014-04-20 14:22:21

标签: date csv graph 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轴上看到一些来自数据文件的记录(没有日期)。我不想在x轴上看到每个日期。我想在x轴上定期看到大约10个日期:

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

我该怎么做?

1 个答案:

答案 0 :(得分:0)

您必须将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

结果似乎是正确的:

enter image description here

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

set format x '%b %Y'

显示Jun 2011 ...