{ TFile *f1 = TFile::Open("c1.root"); TCanvas *c = (TCanvas *)f1->Get("c1"); TGraphErrors *g1 = (TGraphErrors *)c->GetListOfPrimitives()->FindObject("Graph"); c->Close(); g1->GetXaxis()->SetRangeUser(0,6); g1->GetYaxis()->SetRangeUser(1,1000); g1->SetMarkerStyle(22); g1->SetMarkerSize(2); g1->SetLineColor(2); g1->SetLineWidth(3); g1->SetLineStyle(9); g1->Draw(""); g1->GetXaxis()->SetNdivisions(509); // gPad->SetLogy(); TFile *f2 = TFile::Open("3.root"); TH1D* h1 = (TH1D*)f2->Get("h16"); h1->SetLineStyle(9); h1->SetMarkerStyle(21); h1->SetMarkerSize(2); h1->SetLineColor(9); h1->SetLineWidth(3); h1->Draw("HIST L P SAME"); auto leg = new TLegend(0.51,0.69,0.9,0.9); leg->SetHeader("S"); leg->AddEntry(g1,"1","l p"); leg->AddEntry(h1, "2","a p l"); leg->Draw(); }