void bar_hist() { // input data const Int_t nx = 8; char *os_X[nx] = {"8","32","128","512","2048","8192","32768","131072"}; float d_35_0[]= {0.75, -3.30, -0.92, 0.10, 0.08, -1.69, -1.29, -2.37}; float d_35_1[]= {1.01, -3.02, -0.65, 0.37, 0.34, -1.42, -1.02, -2.10}; TCanvas *c1 = new TCanvas("rErrorC","",200,10,928,500); c1->SetGrid(); c1->SetBottomMargin(0.1); c1->SetFillColor(10); c1->SetBorderMode(0); gStyle->SetHistMinimumZero(kTRUE); TH1F *h = new TH1F("h","",nx,0,nx); h->SetFillColor(4); h->SetBarWidth(0.4); h->SetBarOffset(0.1); h->SetStats(0); h->SetMinimum(-5); h->SetMaximum(5); for (i=1;i<=nx;i++) { h->Fill(os_X[i-1], d_35_0[i-1]); h->GetXaxis()->SetBinLabel(i,os_X[i-1]); } h->Draw("bar1"); TH1F *h2 = new TH1F("h","test",nx,0,nx); h2->SetFillColor(38); h2->SetBarWidth(0.4); h2->SetBarOffset(0.5); h2->SetStats(0); for (i=1;i<=nx;i++) { h2->Fill(os_X[i-1], d_35_1[i-1]); } h2->Draw("bar2,same"); TLegend *leg = new TLegend(0.77184,0.833333,0.981501,0.927711); leg->SetTextSize(0.03); leg->SetBorderSize(2); leg->SetMargin(0.15); leg->SetFillColor(10); leg->AddEntry(h,"35.0","f"); leg->AddEntry(h2,"35.1","f"); leg->Draw(); }