2
votes

I can't seem to figure out how to get gnuplot to parse my dates despite trying every combination. I'm trying to create a chart with years on the x axis and month and days on the y axis. All I get as a result is a chart with a line going from the bottom left to upper right and the date on the y axis is stuck on "01/01" and for the life of me I don't know what is wrong. Included here is my effort going back to the most basic setup:

I have a script which loops over an int and calls:

for c in `seq 2014 2015`;
do
w=$(ncal -e -y $c)
e=$(ncal -o -y $c)
echo $c, $w, $e
done

This creates data such as:

2014, April 20 2014, April 20 2014
2015, April 5 2015, April 12 2015
...

Gnuplot commands:

set ydata time
set format y "%m/%d"
set timefmt "%B %d %Y"
set datafile separator ","

plot "< ./dump.sh" using 1:2 with lines title "western", \
    "< ./dump.sh" using 1:3 with lines title "eastern"

Any help would be appreciated.

1
When I try this, I get a y-axis with alternating '01/01' and '07/01', which is what I'd expect - Its giving the first and middle dates of the year. You might consider setting the y-tics to be at the actual dates you read from the script. Unfortunately, I don't know how to do this off the top of my head. See gnuplot.sourceforge.net/docs_4.2/node295.html - darthbith

1 Answers

1
votes

The output format for the y-axis affects only the labels, but not the positions. So having only month and day in the ytic labels still includes the increasing years, which gives you the line.

Just use set timefmt "%B %d", which ignores the rest of the time string:

set datafile separator ","
set timefmt "%B %d"
set ydata time
set format y "%m/%d"

set style data lines
plot "< ./dump.sh" using 1:2 title "western", \
    "< ./dump.sh" using 1:3 title "eastern"

Not using an explicit year uses either 2000 (version 4.6) or 1970 (development version) for the data. But that shouldn't matter at all for you application.

That gives (with 4.6.3):

enter image description here