int macro_GoodPlotExample () { gStyle->SetOptStat (0); gStyle->SetLegendBorderSize (0); gStyle->SetLegendTextSize (0.055); gStyle->SetLabelSize (0.055, "XY"); gStyle->SetNdivisions ( 505 , "XY"); /*** Stage 1: generating some dummy data ***/ TH1F* h1 = new TH1F ("h1", "", 200, -14, 10); h1->FillRandom ("gaus", 30000); h1->SetLineWidth (2); h1->SetLineColor (kBlack); h1->SetFillColor (19); TF1* f1 = new TF1 ("f1", "1000*abs(sin(x)/x)", -14, 14); f1->SetLineColor (kBlue); Int_t i = 0; Double_t x[50], y[50], ex[50], ey[50]; for (Double_t xval = -9; xval <= 9; xval++, i++) { x[i] = xval; y[i] = 1000 * sin ( (xval + 9)/10 ) ; ex[i] = 0.3; ey[i] = (xval+9) * 3 ; } TGraphErrors* gr = new TGraphErrors (i, x, y, ex, ey); gr->SetName ("gr"); gr->SetMarkerStyle (21); gr->SetMarkerColor (kRed); /*** Stage 2: Data visualization ***/ TCanvas* c1 = new TCanvas ("c1", "", 800, 600); c1->SetGrid (0, 0); c1->SetTopMargin (0.05); c1->SetBottomMargin (0.15); c1->SetRightMargin (0.04); c1->SetLeftMargin (0.16); h1->Draw (); f1->Draw ("same"); gr->Draw ("P"); TLegend* leg = new TLegend (0.21, 0.63, 0.5, 0.86, "", "nbNDC"); leg->AddEntry ( h1 , " Experiment" , "f" ); leg->AddEntry ("f1", " Model" , "l" ); leg->AddEntry ("gr", " Efficiency" , "lep"); leg->Draw (); TLatex l; l.SetNDC (1); l.SetTextSize (0.055); l.DrawLatex (0.44, 0.025, "Position (#mum)"); l.SetTextAngle (90); l.DrawLatex (0.035, 0.34 , "Rate (arb. units)"); l.SetTextAngle (0); return 0; }