• Posts
  • RSS
  • ◂◂RSS
  • Contact

  • Timestamp range in gnuplot

    June 20th, 2011
    gnuplot, tech  [html]
    In gnuplot, you might have some data you'd like to graph that has timestamps:
         1308369601 0.15
         1308369661 0.05
         1308369721 0.43
         1308369781 0.41
         ...
      
    You can see many places that to tell gnuplot your xaxis is in seconds since the epoch you use:
         set xdata time
         set timefmt "%s"
         set format x "%H:%M"     # or anything else
         set xlabel "time"
      
    If you want to limit the range, you might think you could do something like:
         set xrange [1308369932:1308373241]
      
    If you try this, you'll get an error like:
         "plot.gnp", line 16: all points y value undefined!
      
    To fix this, you need to subtract 946684800 from the start and end of your xrange:
         set xrange [1308369932-946684800:1308373241-946684800]
      
    What is going on here? It turns out that unlike everything sensible in the unix world, gnuplot calculates time in seconds since the beginning of the year 2000 instead of the year 1970. So it interprets [1308369932:1308373241] as early morning 2041-06-17 instead of early morning 2011-06-18. The magic number, 946684800, is the number of seconds between 2000-01-01 and 1970-01-01.

    I understand gnuplot was trying to be platform independent, but it's pretty annoying now that the 1970 epoch has become dominant.

    Recent posts on blogs I like:

    Learning Worst Industry Practices

    If I have a bad idea and you have a bad idea and we exchange them, we now have two bad ideas. But more than that. If I have a bad idea and you have a good idea and we exchange them, we should both land on your good idea – but that requires both […]

    via Pedestrian Observations September 20, 2020

    Collections: Iron, How Did They Make It? Part I, Mining

    This week we are starting a four-part look at pre-modern iron and steel production. As with our series on farming, we are going to follow the train of iron production from the mine to a finished object, be that a tool, a piece of armor, a simple nail, a w…

    via A Collection of Unmitigated Pedantry September 18, 2020

    Learning Game

    I came up with this game. In the game one person thinks of something and then gives the other person a clue. And the other person writes a guess down on a blackboard or a piece of paper. Or really anything you have that's laying around that's av…

    via Lily Wise's Blog Posts September 17, 2020

    more     (via openring)


  • Posts
  • RSS
  • ◂◂RSS
  • Contact