void drawhistcustom() { TCanvas *c = new TCanvas("c","custom option to draw an histogram",700,500); TH1F *h = new TH1F("h", "h", 100, -5, 5); h->FillRandom("gaus", 10000); TExec *ex = new TExec("ex","DrawBin();"); h->GetListOfFunctions()->Add(ex); h->Draw("P"); } void DrawBin() { TLine *l; TH1F *h = (TH1F*)gPad->GetListOfPrimitives()->FindObject("h"); int n = h->GetNbinsX(); Double_t x1,x2,y; for (int i=1; i<=n; i++) { y = h->GetBinContent(i); x1= h->GetBinLowEdge(i); x2 = h->GetBinWidth(i)+x1; l= new TLine(x1,y,x2,y); l->Paint(); } }