Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Combining xticlabels and xtic <incr>

539 views
Skip to first unread message

bmearns

unread,
Nov 7, 2009, 4:25:12 PM11/7/09
to
I'm trying to plot timestamped data (timestamp on the X axis,
entropy_avail on the Y): I want to format the tic-labels for the X-
axis to display as user friendly date strings but also only show tic
marks once per day. Each of these alone is easy: to format the tic
labels I use xticlabels and the system function to invoke the system's
date command to format the column-1 data, which is the timestamp:
plot "entropy_avail.dat" using 1:2:xticlabels(system(sprintf("date -d @
%d +\"%%m/%%d/%%y %%H:%%M\"", $1)))

To only show tic marks once each day, I do:
set xtics 86400

However, If I try to combine these, it doesn't work: I get the
formatted tic labels, but for every data point. I think because it's
using the ticlabels, not the actual data values, to evaluate the
'xtics <incr>'.

Is there a way to do what I want?

Thanks,
-Brian

sfeam

unread,
Nov 7, 2009, 7:12:26 PM11/7/09
to
bmearns wrote:

I'm not at all sure I understand what you are aiming for, but
experimenting with these commands may help:

# Make the minor (unlabelled) tics longer than default
set xtics scale 1.0, 2.0
# set major tics every 100 days, not overlapping range of data
set xtics 86400*100
# fill in with minor tics every day
set mxtics 100
# Now add to the mix by picking up labeled major tics from the data
plot ... xticlabels(foo($1))

Hans-Bernhard Bröker

unread,
Nov 8, 2009, 8:36:37 AM11/8/09
to
bmearns wrote:
> Each of these alone is easy: to format the tic
> labels I use xticlabels and the system function to invoke the system's
> date command to format the column-1 data, which is the timestamp:
> plot "entropy_avail.dat" using 1:2:xticlabels(system(sprintf("date -d @
> %d +\"%%m/%%d/%%y %%H:%%M\"", $1)))

To me it seems you're trying way too hard. gnuplot's internal time/date
handling should be entirely sufficient for what you're trying to do:

set xdata time
set timefmt '%s'
set format '%m/%d/%y %H:%M'


plot 'entropy_avail.dat' using 1:2

> However, If I try to combine these, it doesn't work: I get the


> formatted tic labels, but for every data point. I think because it's
> using the ticlabels, not the actual data values, to evaluate the
> 'xtics <incr>'.

No. It's because xticlabels(<n>) does exactly what you don't want: one
x-axis ticklabel per data record. 'set xtics' has no effect whatsoever
on a plot using the xticlabels(<n>) option.

bmearns

unread,
Nov 9, 2009, 8:24:52 PM11/9/09
to

Thank you very much. You're exactly right, of course, I just didn't
know enough about gnuplot processing of time and date. I came up with
the following:

set xdata time
set timefmt "%s"

set format x "%b %d - %Y"
#Only show labels once per day
set xtics rotate 86400
plot "timeStampedData.dat" using 1:2 notitle with steps

Thanks
-Brian

0 new messages