#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 densities() { const char *datain = "densities.txt"; const char *dataout = "simulazione/densities.png"; TCanvas *c01 = new TCanvas("c01","multigraph",1280,1024); auto mg = new TMultiGraph(); c01->SetLogy(); 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); TGraph *graph1 = new TGraph(datain,"%lg %lg lg"); TGraph *graph2 = new TGraph(datain,"%lg lg %lg"); graph1->SetMarkerColor(kBlue); graph1->SetLineColor(kBlue); graph1->SetMarkerStyle(3); graph1->SetMarkerSize(1.3); graph1->SetLineWidth(line); mg->Add(graph1); gPad->Update(); graph2->SetMarkerColor(kGreen); graph2->SetLineColor(kGreen); graph2->SetMarkerStyle(3); graph2->SetMarkerSize(1.3); graph2->SetLineWidth(line); mg->Add(graph2); gPad->Update(); mg->SetTitle(""); mg->GetXaxis()->SetTitle("R (mm)"); mg->GetYaxis()->SetTitle("Energy Density (J/cm^{3})"); 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->Draw("ap"); graph1->GetXaxis()->SetNdivisions(10); //numero di punti * 2 ( TLegend* leg = new TLegend(0.75, 0.75, .85, .85); gPad->Update(); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(graph1, "Target 1", "ap"); leg->AddEntry(graph2, "Target 2", "ap"); leg->Draw(); gPad->Update(); c01->Print(dataout); }