#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 const char *data01; const char *dataout; void lcplot() { gStyle->SetOptFit(0); //no print stat TString TitleTString = TString::Format(" "); TString XTitleTString = "Time [MJD]"; TString YTitleTString = "Flux [MeV cm^{-2} s^{-1}]"; data01= "LCdata.txt"; dataout= "LCPeakflare.png"; TCanvas *c01 = new TCanvas("c01","graph",1600,900); // c01->SetLogy(); gStyle->SetOptStat(111110); float offx=1.; 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(data01,"%lg %lg %lg %lg"); graph1->Scale(1./1e-5, "y"); printf("%d\n",graph1->GetN()); graph1->SetMarkerColor(kBlue); graph1->SetLineColor(kBlue); graph1->SetMarkerStyle(8); graph1->SetMarkerSize(2); graph1->SetLineWidth(line); graph1->GetXaxis()->SetTitle(XTitleTString); graph1->GetYaxis()->SetTitle(YTitleTString); graph1->SetTitle(TitleTString); 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->GetXaxis()->SetLimits(60479, 60492); // graph1->GetYaxis()->SetMaxDigits(2); //graph1->GetYaxis()->SetDecimals(1); graph1->Draw("AP"); // graph1->SetMaximum(5.5e-5); //graph1->SetMinimum(1.e-6); TLegend* leg = new TLegend(0.8, 0.73, 1, .88); leg->SetHeader(" "); leg->SetNColumns(1); leg->AddEntry(graph1, "Data", "ap"); leg->SetBorderSize(0); leg->SetFillStyle(0); //leg->Draw(); c01->Modified(); c01->Update(); c01->Print(dataout); }