Re: Problem with a time axis grid

From: Nicolas Arnaud <narnaud_at_lal.in2p3.fr>
Date: Wed, 07 Dec 2005 09:41:32 -0800

Bonjour Olivier,

> Can you send a small running macro showing the problem ?

You can find it below.

The output I got can be found at:

http://www.slac.stanford.edu/~narnaud/problem.gif

The vertical grid lines are drawn at 16:00 'instead of' 00:00

[I'm using ROOT 4.04-02 on Scientific Linux]

Amicalement,

Nicolas


#include <iostream>

Int_t grid()
{
  TDatime T0( 1999, 01, 01, 00, 00, 00 );   timeOffset = T0.Convert();
  gStyle->SetTimeOffset( timeOffset );

  Int_t stopTime = 1133971200;
  Int_t startTime = stopTime - 86400 * 14;

  cout << "startTime = " << startTime

       << " stopTime = " << stopTime << endl;

   TH2F* scope = new TH2F( "scope", "Stripchart",

			   100, startTime - timeOffset,
			   stopTime - timeOffset,
			   100, -2, 2 );

   Float_t omega = 0.000072722;

   Int_t currentTime = startTime;

   while( currentTime <= stopTime )

     {
       //cout << "time = " << currentTime << endl;
       Float_t correctedTime = currentTime - timeOffset;
       Float_t quantity = sin( omega * correctedTime );
       scope->Fill( correctedTime, quantity );
       currentTime += 60;
     }

   TCanvas *c1 = new TCanvas( "c1", "c1", 1024, 768 );    gPad->SetGrid();

   scope->GetXaxis()->SetNdivisions( 14 );
   scope->GetXaxis()->SetTimeDisplay( 1 );
   scope->GetXaxis()->SetTimeFormat( "%y-%m-%d:%H:%M" );
   scope->GetXaxis()->SetLabelSize( 0.01 );
   scope->SetStats( kFALSE );
   scope->Draw();

  return( 0 );
}


Received on Wed Dec 07 2005 - 18:43:36 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:14 MET