{ gROOT->Reset(); // first make a canvas and a 2D histogram for the axes TCanvas* c1 = new TCanvas("c1", "c1", 10, 10, 500, 500); c1->SetBottomMargin(0.18); c1->SetLeftMargin(0.18); // can make histogram or alternatively use the histograms automatically // connected to the TF1 objects // TH2F* axhist = new TH2F("axhist", "title", 10, 0, 10.0, 10, -1.0, 1.0); TF1* f1 = new TF1("f1","1263.",0,20); // need to set these before axes draw, since f1 gets drawn at same time f1->SetLineStyle(1); f1->SetLineWidth(1); // root manipulates the axes using an associated histogram TH1* axhist = f1->GetHistogram(); axhist->SetMinimum(1050); // y axis min and max axhist->SetMaximum(1400); axhist->SetAxisRange(0., 15.0); // x axis gStyle->SetOptStat(0); axhist->SetTitle(""); // turn off title axhist->SetXTitle("number of free parameters"); axhist->SetYTitle("I[0.6,0.8]"); // axhist->GetYaxis()->SetLimits(0.0, 10.0); // can reset limits gStyle->SetOptLogy(0); // 1 for log scale // See TStyle for how to change attributes axhist->GetXaxis()->SetTitleOffset(1.2); // factor multiplies default offset axhist->GetYaxis()->SetTitleOffset(2.0); axhist->GetXaxis()->SetTitleSize(0.04); // default = 0.04 (??? in manual, 0.02) axhist->GetYaxis()->SetTitleSize(0.04); axhist->GetXaxis()->SetNdivisions(8); // N2*100+N1 (N2=secondary, N1=primary) axhist->GetYaxis()->SetNdivisions(8); // N2*100+N1 (N2=secondary, N1=primary) axhist->GetXaxis()->SetLabelSize(.04); axhist->GetYaxis()->SetLabelSize(.04); axhist->GetXaxis()->SetLabelOffset(0.01); axhist->GetYaxis()->SetLabelOffset(0.015); axhist->GetXaxis()->SetTickLength(0.015); // default = 0.03 axhist->GetYaxis()->SetTickLength(0.015); // default = 0.03 axhist->GetXaxis()->SetLabelFont(42); // default = 62 axhist->GetYaxis()->SetLabelFont(42); axhist->GetXaxis()->SetTitleFont(42); axhist->GetYaxis()->SetTitleFont(42); gStyle->SetHistLineWidth(1); // Default:1 --- Line width of histogram gStyle->SetLineWidth(.5); // Default:1 --- Line width of axis. gROOT->ForceStyle(); // c1->GetFrame()->SetBorderSize(6); // from root cheat sheet (???) // c1->GetFrame()->SetBorderMode(-1); axhist->Draw(); // this draws the axes // now add some stuff to the graph f1->SetLineStyle(1); f1->SetLineWidth(1); f1->Draw("same"); string filename = "integralVsNpar.txt"; ifstream textfile; textfile.open(filename.c_str()); if( !textfile.good() ) { cerr << "Cannot open the file: \"" << filename+"\"!"<> x[i] >> y[i] >> dy[i]; dx[i] = 0.; i++; } int numPoints = i; textfile.close(); // kDot=1, kPlus, kStar, kCircle=4, kMultiply=5, // kFullDotSmall=6, kFullDotMedium=7, kFullDotlarge=8, // kFullCircle=20, kFullSquare=21, kFullTriangleUp=22, // kFullTriangleDown=23, kOpenCircle=24, kOpenSquare=25, // kOpenTriangleUp=26, kOpenDiamond=27, kOpenCross=28, // kFullStar=29, kOpenStar=30 // TGraph* tg = new TGraph(3, x, y); TGraphErrors* tg = new TGraphErrors(numPoints, x, y, dx, dy); gStyle->SetEndErrorSize(0); tg->SetMarkerSize(0.7); tg->SetMarkerStyle(20); tg->Draw("P"); }