#include "TH1.h" #include "TF1.h" #include "TLegend.h" #include "TCanvas.h" #include "math.h" TLegend *BuilLegend(TMultiGraph *mg, Double_t x1, Double_t y1, Double_t x2, Double_t y2, char* title, char* names[5]); void plot_graph() { TCanvas *c1 = new TCanvas("ewb", "ewb",281,93,700,500); c1->SetGrid(); Int_t ypoints[13] = {1,1,1,1,1,1,1,1,1,1,1,1,1}; Int_t xpoints[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; TGraph *gr1 = new TGraph(13, xpoints, ypoints); Int_t xpoints1[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; Int_t ypoints1[13] = {2,2,2,2,2,2,2,2,2,2,2,2,2}; TGraph *gr2 = new TGraph(13, xpoints1, ypoints1); TMultiGraph *mgr = new TMultiGraph("mgr", "mgr"); mgr->Add(gr2); mgr->Add(gr1); TH1 *h1 = mgr->GetHistogram(); h1->Rebin(); // Get by default returns a TObject, hence we need to typecast it std::vector label; label.push_back("6.3x10^{-5}"); label.push_back("1.0x10^{-4}"); label.push_back("4.7x10^{-4}"); label.push_back("0.0010"); label.push_back("0.0027"); label.push_back("0.0100"); label.push_back("0.0460"); label.push_back("0.0500"); label.push_back("0.1000"); label.push_back("0.3170"); label.push_back("0.5000"); label.push_back("0.7000"); label.push_back("0.9000"); mgr->Draw("ALP"); Int_t i; for (i=1;i<=13;i++) { mgr->GetXaxis()->LabelsOption("d"); int bin = mgr->GetXaxis()->FindBin(i); mgr->GetXaxis()->SetBinLabel(bin,label[i-1].c_str()); } mgr->SetTitle("1-Dim"); mgr->GetXaxis()->SetTitle("cut on p-value"); mgr->GetYaxis()->SetTitle("fraction of survivors"); mgr->Draw("ALP"); }