Logo ROOT  
Reference Guide
timeonaxis2.C File Reference

Detailed Description

View in nbviewer Open in SWAN Define the time offset as 2003, January 1st.

TCanvas *timeonaxis2() {
TCanvas *ct2 = new TCanvas("ct2","ct2",10,10,700,500);
TDatime T0(2003, 1, 1, 0, 0, 0);
int X0 = T0.Convert();
// Define the lowest histogram limit as 2002, September 23rd
TDatime T1(2002, 9, 23, 0, 0, 0);
int X1 = T1.Convert()-X0;
// Define the highest histogram limit as 2003, March 7th
TDatime T2(2003, 3, 7, 0, 0, 0);
int X2 = T2.Convert(1)-X0;
TH1F * h1 = new TH1F("h1","test",100,X1,X2);
for (Int_t i=0;i<30000;i++) {
Double_t noise = r.Gaus(0.5*(X1+X2),0.1*(X2-X1));
h1->Fill(noise);
}
h1->GetXaxis()->SetTimeFormat("%Y/%m/%d");
h1->Draw();
return ct2;
}
Author
Olivier Couet

Definition in file timeonaxis2.C.

r
ROOT::R::TRInterface & r
Definition: Object.C:4
Int_t
int Int_t
Definition: RtypesCore.h:45
TAxis::SetTimeFormat
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition: TAxis.cxx:1020
TAxis::SetTimeDisplay
virtual void SetTimeDisplay(Int_t value)
Definition: TAxis.h:161
h1
TH1F * h1
Definition: legend1.C:5
TAttAxis::SetLabelSize
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
Definition: TAttAxis.cxx:203
TRandom
Definition: TRandom.h:27
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
TH1::Fill
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3274
T2
#define T2
Definition: md5.inl:146
TStyle::SetTimeOffset
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition: TStyle.cxx:1803
Double_t
double Double_t
Definition: RtypesCore.h:59
TCanvas
Definition: TCanvas.h:23
TH1F
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:572
T1
#define T1
Definition: md5.inl:145
TDatime
Definition: TDatime.h:37
TH1::GetXaxis
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:317
TH1::Draw
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2997