void test_time_axis() { TTimeStamp dateLo(2012, 01, 01, 00, 00, 00); TTimeStamp dateHi(2012, 06, 02, 00, 00, 00); time_t numDays = ((dateHi.GetSec() - dateLo.GetSec()) / (24 * 60 * 60)) + 1; TTimeStamp a(dateLo); TTimeStamp b(dateHi); // Careful with this magic. It centers the bins on the days. b.SetSec(b.GetSec() + (24 * 60 * 60)); a.SetSec(a.GetSec() - (60 * 60)); b.SetSec(b.GetSec() - (60 * 60)); TH1F* hTest = new TH1F("", "", numDays, a.GetSec(), b.GetSec()); for (size_t i = 0; i != numDays; ++i) { hTest->SetBinContent(i + 1, i + 1); } hTest->SetLineWidth(2); hTest->GetXaxis()->SetTimeDisplay(1); hTest->GetXaxis()->SetTimeFormat("%d/%m"); hTest->GetXaxis()->SetTimeOffset(0, "gmt"); TCanvas* canvas = new TCanvas("canvas", "Canvas", 10, 10, 1800, 1400); hTest->Draw(); canvas->Print("test_time_axis.png"); }