At the time OP's question gnuplot 5.0 was already out. Anyway, it is somehow possible with gnuplot 4.6 and maybe with some cumbersome workaround even with gnuplot 4.4 (no sum
or stats
) at that time.
The following solution tries to avoid the disadvantage of @maij's solution with a hardcoded range and tic distances.
However, you need to plot twice, the first time just to get gnuplot's autoscaled range via the variables GPVAL_X_MIN
and GPVAL_X_MAX
which you only get after plotting. Depending on the width of the output graph you can set the variable maxLabelCount
. There is certainly room for improvements.
Script: (works for gnuplot>=5.0.0, Jan. 2015)
### replace midnight xtic time by date
reset session
FILE = "SO39997342.dat"
SecPerHour = 3600
SecPerDay = 24*SecPerHour
myTimeFmtIn = "%Y-%m-%d_%H:%M"
# create some random test data
set table FILE
set samples 60
t0 = time(0)
plot '+' u (strftime(myTimeFmtIn, t0+$0*SecPerHour)):(sin($0/10.)+rand(0)*0.4-0.2) w table
unset table
myTimeFmtOut = "%H:%M"
set format x myTimeFmtOut timedate
set key noautotitle
set grid x,y
plot FILE u (timecolumn(1,myTimeFmtIn)):2 w l
isMidnight(t) = int(t)/SecPerDay == t/SecPerDay
myXtic(t) = isMidnight(t) ? strftime("{/:Bold %b %d}",t) : strftime(myTimeFmtOut,t)
n2t(i) = d0*SecPerDay + i*SecPerDay*d2
maxLabelCount = 8
numberOfDays = (d0=ceil(GPVAL_X_MIN/SecPerDay),d1=floor(GPVAL_X_MAX/SecPerDay),d1-d0)
getNLabels(c,cmax) = (c0=0, c<=cmax ? (c0=c,d2=1) : (sum [j=2:cmax] (c/j<=cmax && !c0 ? (c0=c/j,d2=j) : 0)), c0)
NLabels = getNLabels(numberOfDays,maxLabelCount)
set for [i=0:NLabels] xtic add (myXtic(n2t(i)) n2t(i))
set xrange[GPVAL_X_MIN:GPVAL_X_MAX]
replot
### end of script
Result: (merged graphs with varying time data ranging from 30 h to 360 h, without changing the rest of the script)

Script: (works with gnuplot>=4.6.0, March 2012)
gnuplot4.4.0 did not have sum
which would require some workaround.
The random test data generation is probably also not possible or difficult in 4.4.0 and 4.6.0.
Furthermore, I couldn't find bold face in gnuplot 4.6.0. Actually, @maij, cool attempt for bold face in gnuplot4.6, however, at some point you will get a bold or double grid line as well.
So, instead I shifted the dates down by one line. Maybe there are better ways to "highlight" the date.
### replace midnight xtic time by date
reset
FILE = "SO39997342.dat"
SecPerHour = 3600
SecPerDay = 24*SecPerHour
myTimeFmtIn = "%Y-%m-%d_%H:%M"
set xdata time
myTimeFmtOut = "%H:%M"
set format x myTimeFmtOut."\n"
set timefmt "%Y-%m-%d_%H:%M"
set key noautotitle
set grid x
set grid y
plot FILE u (timecolumn(1)):2 w l
isMidnight(t) = int(t)/SecPerDay == t/SecPerDay
myXtic(t) = isMidnight(t) ? strftime("\n%b %d",t) : strftime(myTimeFmtOut,t)
n2t(i) = d0*SecPerDay + i*SecPerDay*d2
maxLabelCount = 8
numberOfDays = (d0=ceil(GPVAL_X_MIN/SecPerDay),d1=floor(GPVAL_X_MAX/SecPerDay),d1-d0)
getNLabels(c,cmax) = (c0=0, c<=cmax ? (c0=c,d2=1) : (sum [j=2:cmax] (c/j<=cmax && !c0 ? (c0=c/j,d2=j) : 0)), c0)
NLabels = getNLabels(numberOfDays,maxLabelCount)
set for [i=0:NLabels] xtic add (myXtic(n2t(i)) n2t(i))
set xrange[GPVAL_X_MIN:GPVAL_X_MAX]
replot
### end of script
Result: (created with gnuplot 4.6.0)
