Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top