#include "TCanvas.h" #include "TPad.h" #include "TMultiGraph.h" #include "TGraph.h" #include "TGraphAsymmErrors.h" #include "TGraphErrors.h" #include "TAxis.h" #include "TLegend.h" #include "TLatex.h" #include "TROOT.h" #include "TPaveStats.h" #include "TStyle.h" #include void muoneneene() { gStyle->SetOptFit(0); //no print stat //gStyle->SetOptFit(); const char *dataBe = "Muon_ene_Beam-energy_Be.txt"; const char *dataC = "Muon_ene_Beam-energy_C.txt"; const char *dataout = "simulazione/Muon_ene_Beam-energy.png"; TCanvas *c01 = new TCanvas("c01","multigraph",1280,1024); //c01->SetLogy(); gStyle->SetOptStat(111110); auto mg = new TMultiGraph(); 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(dataBe,"%lg %lg %lg %lg"); TGraphErrors *graph2 = new TGraphErrors(dataC,"%lg %lg %lg %lg"); printf("%d %d \n",graph1->GetN(),graph2->GetN()); graph1->SetMarkerColor(kBlue); graph1->SetLineColor(kBlue); graph1->SetMarkerStyle(5); graph1->SetMarkerSize(6); graph1->SetLineWidth(line); //graph1->SetLineStyle(8); mg->Add(graph1); graph2->SetMarkerColor(kGreen); graph2->SetLineColor(kGreen); graph2->SetMarkerStyle(5); graph2->SetMarkerSize(6); graph2->SetLineWidth(line); //graph2->SetLineStyle(8); mg->Add(graph2); mg->SetTitle(""); mg->GetXaxis()->SetTitle("Beam energy (GeV)"); mg->GetYaxis()->SetTitle(" (GeV)"); mg->GetYaxis()->SetTitleOffset(offy); mg->GetXaxis()->SetTitleOffset(offx); mg->GetYaxis()->SetTitleSize(40); mg->GetYaxis()->SetTitleFont(43); mg->GetYaxis()->SetLabelFont(43); mg->GetYaxis()->SetLabelSize(40); mg->GetXaxis()->SetTitleSize(40); mg->GetXaxis()->SetTitleFont(43); mg->GetXaxis()->SetLabelFont(43); mg->GetXaxis()->SetLabelSize(40); //mg->GetXaxis()->SetNdivisions(6); // //mg->SetMinimum(1.e-10); //mg->SetMaximum(1.5e-5); mg->Draw("AP"); TLegend* leg = new TLegend(0.2, 0.78, .3, .88); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(graph1, "Beryllium", "ap"); leg->AddEntry(graph2, "Carbon", "ap"); //leg->Draw(); c01->Update(); c01->Print(dataout); }