Re: Problem with a time axis grid

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Thu, 8 Dec 2005 11:33:42 +0100 (CET)

Bonjour Nicolas,

Just do:

  scope->GetXaxis()->SetNdivisions(-14 );

a negative number of divisions means that the number of divisions is not optimized (by default it is). I tried, it works for me.

Amicalement,

Olivier

On Wed, 7 Dec 2005, Nicolas Arnaud wrote:

>
> 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 );
> }
>
> -------------------------------
>
>

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Thu Dec 08 2005 - 11:33:47 MET

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