void DrawGrid(TString t, Int_t ngx, Int_t ngy) { Double_t x1 = -10; Double_t x2 = 20; Double_t y1 = 10; Double_t y2 = 40; Double_t xs = (x2-x1)/ngx; Double_t ys = (y2-y1)/ngy; Int_t i; TH1F *h = gPad->DrawFrame(x1, y1, x2, y2); h->GetXaxis()->SetNdivisions(20); h->GetYaxis()->SetNdivisions(20); h->GetYaxis()->SetTickLength(0.); h->GetXaxis()->SetTickLength(0.); h->GetXaxis()->SetLabelSize(0.025); h->GetYaxis()->SetLabelSize(0.025); h->SetTitle(t.Data()); gPad-> Update(); TLine l; l.SetLineColor(kGray); Double_t x = x1+xs; for (i = 0; iSetTitle("Before"); before->SetMarkerStyle(kFullCircle); before->SetMarkerColor(kBlue); DrawGrid("Before/After plot", 100, 100); before->Draw("P"); Double_t a[10] = {-1.,2.,-3.,4.,-5.,1.,2.,-6.,7.,-8.}; Double_t b[10] = {25.,24.,22.,31.,32.,27.,23.,35.,38.,22.}; TGraph *after = new TGraph(10, a, b); after->SetMarkerStyle(kFullCircle); after->SetMarkerColor(kRed); after->Draw("P"); }