tags:

views:

901

answers:

1

My input to gnuplot looks something like this:

1:00am  1       10
1:00am  30      12
1:01am  60      18
1:01am  90      20
1:02am  120     21
...

The first column contains (what I'd like to be) the X-axis labels, while the second column contains the X-axis values. (In actual point of fact, I have one row per second, so many rows have '1:00am' as in the label column, then '1:01am', etc).

I can plot the values I care about using something like:

gnuplot> plot "my_data.txt" using 2:3 with lines

And I can set the X axis to have a tick (and label) every 30 minutes (which is 30 * 60 = 1800 seconds), but the label it uses is the X axis value (something like 3600 for one hour).

What I can't get is for the labels that show up under each tick to use the values from the first column. I can't even find anything that looks promising in the gnuplot manual. I've got to assume this is possible, I just don't know where to look.

Edit:

Progress, I've discovered the xticlabels() parameter to plot. The problem is that it seems to plot these labels for every xtic (that is, one per second in my data set), rather than at the intervals defined by set xtics.

Edit and Answer:

Turns out gnuplot has support for graphing time-series data. For the curious:

set timefmt "%H:%M:%S"
set xdata time

This causes the X axis data (once reformatted to match that pattern) to be interpreted as time-series data. This is then combined with

set xtics 3600

Formats the X axis as I described.

+1  A: 

Sorry caught this late, but yes was to suggest set timefmt ... ; set xdata time. I always pass in my time format as %s but just as a common practice.

Xepoch
Yup, that was the solution I used. I'll check the answer even though it was a little late :-P
dcrosta
Thanks! :) Forgot to add gnuplot as a personal tag :)
Xepoch