#include "TCanvas.h" #include "TPad.h" #include "TMultiGraph.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TAxis.h" #include "TLegend.h" #include "TLatex.h" #include "TROOT.h" #include "TPaveStats.h" #include "TStyle.h" #include void posratio() { gStyle->SetOptFit(0); //no print stat //gStyle->SetOptFit(); const char *datain = "Pos_ratio_number_Be.txt"; // const char *datain = "Pos_ratio_number_C.txt"; const char *dataout = "Pos_ratio_number_circ_Be.png"; // const char *dataout = "Pos_ratio_number_circ_C.png"; TCanvas *c01 = new TCanvas("c01","graph",1280,1024); //c01->SetLogy(); gStyle->SetOptStat(111110); float offx=1.3; float offy=1.3; float margr=0.08; float w=3; float margl=0.12; float line=2; gPad->SetLeftMargin(margl); gPad->SetRightMargin(margr); TGraphErrors *graph1 = new TGraphErrors(datain,"%lg %lg 0 %lg"); printf("%d \n",graph1->GetN() ); graph1->SetMarkerColor(kBlue); graph1->SetLineColor(kBlue); graph1->SetMarkerStyle(3); graph1->SetMarkerSize(1.3); graph1->SetLineWidth(line); graph1->SetTitle(); graph1->GetXaxis()->SetTitle("Thickness (mm)"); graph1->GetYaxis()->SetTitle("Ratio"); graph1->GetYaxis()->SetTitleOffset(offy); graph1->GetXaxis()->SetTitleOffset(offx); graph1->GetYaxis()->SetTitleSize(40); graph1->GetYaxis()->SetTitleFont(43); graph1->GetYaxis()->SetLabelFont(43); graph1->GetYaxis()->SetLabelSize(40); graph1->GetXaxis()->SetTitleSize(40); graph1->GetXaxis()->SetTitleFont(43); graph1->GetXaxis()->SetLabelFont(43); graph1->GetXaxis()->SetLabelSize(40); graph1->SetLineStyle(10); graph1->SetMarkerSize(5); graph1->Draw(); /* TLegend* leg = new TLegend(0.15, 0.80, .25, .85); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(graph1, "Data", "ap"); leg->AddEntry(fit, "Fit", "l"); leg->Draw();*/ c01->Update(); c01->Print(dataout); }