Re: Wrong year displayed with time on a TGraph axis

From: Olivier Couet <couet_at_mail.cern.ch>
Date: Mon, 7 Mar 2005 11:55:49 +0100 (CET)

Hi Brett,

 try this one:

timeonaxis4 ()
{

   TGraph *graph = new TGraph;
   gStyle->SetTimeOffset(0);

   graph->SetPoint(0,1109363595.051000,1.0);
   graph->SetPoint(1,1109376948.212000,2.0);
   graph->Draw("AC*");

   TH1F *hist = graph->GetHistogram();
   TAxis *axis = hist->GetXaxis();
   axis->SetTimeDisplay(1);
   axis->SetTimeFormat("%Y-%m-%d");
   axis->SetNdivisions(202,false);

}

I didn't find the piece of documentation you are referring to (concerning %F). Where is that ? (I looked in TAxis::SetTimeFormat code and in the latest printed manual).

Cheers, Olivier

On Fri, 4 Mar 2005, Brett Viren wrote:

> Hi,
>
> The following produces years displayed as "30" instead of "05".
>
> //--------------------//
> {
> graph = new TGraph;
> graph->SetPoint(0,1109363595.051000,1.0);
> graph->SetPoint(0,1109376948.212000,2.0);
> graph->Draw("AB");
> frame = graph->GetHistogram();
> axis = frame->GetXaxis();
> axis->SetTimeDisplay(1);
> axis->SetTimeFormat("%y-%m-%d %H:%M:%S");
> axis->SetNdivisions(202,false);
> axis->SetAxisColor(2);
> c1->Modified();
> c1->Update();
> }
> //--------------------//
>
>
> That first timestamp should correspond to
> Fri Feb 25 20:33:15 2005 UTC
>
> I'm using CVS from last night on Debian x86 GCC 3.3.5.
>
> Any ideas?
>
>
> Also, there is a conflict in the documentation for
> TAxis::SetTimeFormat. It states that one can use the codes as
> defined in strftime(3). However, in that man page it says:
>
> %F Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
>
> whereas SetTimeFormat() uses this code to define a time offset.
>
>
> Thanks,
> -Brett.
>
>

-- 
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 Mon Mar 07 2005 - 11:55:54 MET

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