Wrong year when using time axis in pyroot

_ROOT Version: v6.20.00
_Platform: iMac running 10.14
_Compiler: Python 2.7

Dear Root experts,

I am trying to use TGraph with a time axis. However while month, day, hour and minutes come out correctly, the year changes from 2020 to 2045. I created a small script to demonstrate this

As output I get

year of test data point: 2020

and the attached screenshot, which shows the year as 2045 on the x-axis. How can I get the correct year here?

Thanks!
Thorsten

Screenshot 2020-03-18 at 15.04.21

taxis.py (1.2 KB)

{
   auto testgraph = new TGraph();

   testgraph->SetPoint(0, TDatime("2020-03-18 09:00:01").Convert(), 0);
   testgraph->SetPoint(1, TDatime("2020-03-18 09:15:00").Convert(), 1);
   testgraph->SetPoint(2, TDatime("2020-03-18 09:30:00").Convert(), 2);
   testgraph->SetPoint(3, TDatime("2020-03-18 09:45:00").Convert(), 3);
   testgraph->SetPoint(4, TDatime("2020-03-18 10:00:01").Convert(), 5);
   testgraph->SetPoint(5, TDatime("2020-03-18 10:15:01").Convert(), 6);
   testgraph->SetPoint(6, TDatime("2020-03-18 10:30:00").Convert(), 7);
   testgraph->SetPoint(7, TDatime("2020-03-18 10:45:01").Convert(), 9);
   testgraph->SetPoint(8, TDatime("2020-03-18 11:00:01").Convert(), 3);

   testgraph->SetMarkerColor( 4 );
   testgraph->SetMarkerStyle( 21 );

   testgraph->GetXaxis()->SetTimeDisplay(1);
   testgraph->GetXaxis()->SetTimeOffset(0);
   testgraph->GetXaxis()->SetNdivisions(503);
   testgraph->GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M");

   testgraph->Draw( "ACP" );
}

Ah yes, adding SetTimeOffset(0) to my code indeed solves this problem. I have to admit I dont really understand why this command has this effect, but it works now. Thanks!

https://root.cern/doc/master/classTStyle.html#a7abb722e873b0e07d4eef2fddbbb39e3

Hello - thanks, that explains it of course.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.