void glabels() { TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500); c1->SetFillColor(42); c1->SetGrid(); const Int_t n = 20; Double_t x[n], y[n]; for (Int_t i=0;iSetFillColor(19); gr->SetLineColor(2); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); gr->SetTitle("a simple graph"); gr->Draw("ACP"); //Add axis titles. //A graph is drawn using the services of the TH1F histogram class. //The histogram is created by TGraph::Paint. //TGraph::Paint is called by TCanvas::Update. This function is called by default //when typing at the keyboard. In a macro, one must force TCanvas::Update. c1->Update(); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(12); TAxis *axis = gr->GetHistogram()->GetXaxis(); axis->SetLabelOffset(999); Double_t ypad = c1->GetUymax()-c1->GetUymin(); Double_t yl = c1->GetUymin() - 0.02*ypad; TText t; t.SetTextSize(0.03); t.SetTextAlign(23); char *year[11] = {"1990","1992","1994","1996","1998","2000","2002", "2004","2006","2008",2010}; for (Int_t i=0;i<10;i++)) { t.DrawText(x[2*i+1],yl,year[i]); } c1->Modified(); }