func time_axis(flag, times, t, sx)
 ;returns 0 if times aren't loaded and 1 if OK
 ;flag is input, if off then we return 0 and sx is set to 'image #'
 ;times are input (e.g., $lightcurve_times) and t and sx are output
 ;t is values for x axis and sx is the label
 tbase = min(times)
 tmax = !lastmax
 sx = 'image #'
 if not(flag) then return, 0
 if tbase le 0.0 then {
  errormess,'time array is invalid\nsorry, only image #''s for plots'
  return, 0 }
 t = times - tbase
 tmax = tmax - tbase
 sq = date_from_tai(tbase,0,1)
 sq1 = strtok(sq,'\n')
 sq2 = strtok('', 'U')
 sq = ' ' + sq1 + ' ' + sq2
 sx = 'time in seconds since'
 if tmax gt 600 then {
   tmax = tmax/60.    t = t/60.
   sx = 'time in minutes since'
   if tmax gt 600 then {
    tmax = tmax/60.    t = t/60.
    sx = 'time in hours since'
    if tmax gt 120 then {
     tmax = tmax/24.    t = t/24.
     sx = 'time in days since' }}}
 sx = sx + sq
 return, 1    
 endfunc
 ;========================================================
