TGraph *graphLH(std::string nuisname, double err ){ w->loadSnapshot("bestfitall"); // SetTo BestFit values as start // Get The parameter we want RooRealVar *nuis =(RooRealVar*) w->var(nuisname.c_str()); double bf = nuis->getVal(); double nll_0=nll->getVal(); TGraph *gr = new TGraph(2*npoints+1); for (int i=-1*npoints;i<=npoints;i++){ nuis->setVal(bf+err*( ((float)i)*nsigma/npoints)); double nll_v = nll->getVal(); gr->SetPoint(i+npoints,nuis->getVal(),nll_v-nll_0); } gr->SetTitle(""); gr->GetYaxis()->SetTitle("NLL - obs data"); gr->GetYaxis()->SetTitleOffset(1.1); gr->GetXaxis()->SetTitleSize(0.05); gr->GetYaxis()->SetTitleSize(0.05); gr->GetXaxis()->SetTitle(nuisname.c_str()); gr->SetLineColor(4); gr->SetLineWidth(2); gr->SetMarkerStyle(21); gr->SetMarkerSize(0.6); return gr; }
void SetTitle(TGraph& g, TString Xtitle, TString Ytitle, TString title){ g.GetXaxis()->SetTitle(Xtitle); g.GetYaxis()->SetTitle(Ytitle); g.GetXaxis()->CenterTitle(); g.GetYaxis()->CenterTitle(); g.SetTitle(title); }
void SetStyle(TGraph& g, double size, int color, int style, int fillstyle=0, int linestyle=1){ g.SetMarkerSize(size); g.SetMarkerColor(color); g.SetLineColor(color); g.SetMarkerStyle(style); g.SetFillStyle(fillstyle); g.SetLineStyle(linestyle); g.GetXaxis()->SetTitleFont(42); g.GetYaxis()->SetTitleFont(42); g.GetXaxis()->SetTitleSize(0.048); g.GetYaxis()->SetTitleSize(0.048); g.GetXaxis()->CenterTitle(); g.GetYaxis()->CenterTitle(); }
void graph() { TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500); c1->SetFillColor(42); c1->SetGrid(); const Int_t n = 20; Double_t x[n], y[n]; for (Int_t i=0;i<n;i++) { x[i] = i*0.1; y[i] = 10*sin(x[i]+0.2); printf(" i %i %f %f \n",i,x[i],y[i]); } TGraph *gr = new TGraph(n,x,y); gr->SetLineColor(2); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); gr->SetTitle("a simple graph"); gr->GetXaxis()->SetTitle("X title"); gr->GetYaxis()->SetTitle("Y title"); gr->Draw("ACP"); // TCanvas::Update() draws the frame, after which one can change it c1->Update(); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(12); c1->Modified(); }
void treegraph(TString filename) { gROOT->SetStyle("Plain"); gStyle->SetOptDate(); Double_t x, y; Int_t nlines = 0; TFile *f = new TFile("graph.root","RECREATE"); TCanvas *canvas_graph = new TCanvas("canvas_graph", "y vs x",467,89,400,700); TTree t; t.ReadFile(filename,"x:y"); t.Draw("x:y","","goff"); TGraph *g = new TGraph(t.GetSelectedRows(),t.GetV1(),t.GetV2()); g->SetTitle(filename+": Y vs X"); g->GetXaxis()->SetTitle("x[a.u.]"); g->GetYaxis()->SetTitle("y[a.u.]"); g->SetMarkerStyle(21); g->Draw("AP"); f->Write(); }
void testing() { //new TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500); c1->SetFillColor(42); c1->SetGrid(); const int n = 20; double x[n], y[n]; for (int i=0;i<n;i++) { x[i] = i; y[i] = 2*i; cout<<x[i]<<"\t"<<y[i]<<endl; } TGraph *gr = new TGraph(n,x,y); gr->SetLineColor(2); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); gr->SetTitle("a simple graph"); gr->GetXaxis()->SetTitle("X title"); gr->GetYaxis()->SetTitle("Y title"); gr->Draw("ACP"); c1->Update(); c1->Modified(); c1->Connect("Closed()", "TApplication", gApplication, "Terminate()"); //new }
//Return a graph of the llscan TGraph * LLscanResult::GetGraph() { double* pvs = new double[parameterValues.size()] ; double* llvs = new double[parameterValues.size()] ; double llmax = 0 ; for(unsigned int i=0; i< parameterValues.size() ; ++i ){ pvs[i] = parameterValues[i] ; llvs[i] = llvalues_offset[i] ; if( llvs[i] > llmax ) llmax = llvs[i] ; } TGraph* gr = new TGraph( Int_t(parameterValues.size()), pvs, llvs ) ; //gr->SetTitle("LL Scan for Parameter xxx"); gr->SetMarkerStyle(1); gr->SetLineWidth(2); gr->SetMarkerColor(4); gr->SetLineColor(4); gr->GetYaxis()->SetRangeUser( 0., llmax*1.2 ); gr->GetYaxis()->SetLimits( 0., llmax*1.2 ); gr->SetMinimum( 0.0 ); gr->SetMaximum( llmax*1.2 ); gr->Draw("ALP"); string title("LL Scan for Parameter ") ; title+=parameterName.c_str(); gr->SetTitle(title.c_str()); gr->GetXaxis()->SetTitle(parameterName.c_str()); return gr ; }
void particleinteractions2() { //Draw a simple graph // To see the output of this macro, click begin_html <a href="gif/graph.gif">here</a>. end_html //Author: Rene Brun TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500); c1->SetFillColor(42); c1->SetGrid(); const Int_t n = 1000; Double_t x[n], y[n]; int minEnergy = ceil(mass*pow(c,2)); for (Int_t i=0; i < 1000;i++) { double energy = minEnergy+i; x[i] = energy; y[i] = exp(-mass*c/(lifetime*sqrt(energy*energy-mass*mass*pow(c, 4)))); printf(" i %i %f %f \n",i,x[i],y[i]); } TGraph *gr = new TGraph(n,x,y); gr->SetLineColor(2); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); gr->SetTitle("Particle Decay Graph"); gr->GetXaxis()->SetTitle("Energy (MeV)"); gr->GetYaxis()->SetTitle("Probability"); gr->Draw("ACP"); // TCanvas::Update() draws the frame, after which one can change it c1->Update(); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(12); c1->Modified(); }
TGraph * makeOBV(TGraph *Graph1){ TGraph *gr = new TGraph(); double X; double Y; int pp=0; Graph1->GetPoint(1,X,Y); for (double MDM=1;MDM<=Y;MDM+=0.1){ gr->SetPoint(pp,MDM,vecF(X,MDM)); pp++; } for (int p =1;p<Graph1->GetN();p++){ Graph1->GetPoint(p,X,Y); if (!(X >1)) continue; std::cout << X << " " << Y << std::endl; gr->SetPoint(pp,Y,vecF(X,Y)); pp++; } gr->GetXaxis()->SetTitle("m_{DM}"); gr->GetYaxis()->SetTitle("#sigma_{SD}"); gr->SetName(Form("%s_DD",Graph1->GetName())); gr->SetLineStyle(Graph1->GetLineStyle()); gr->SetLineColor(Graph1->GetLineColor()); gr->SetLineWidth(Graph1->GetLineWidth()); return gr; }
void plotChi2(TTree *dataTree, TTree *mcTree, TCut dataCandidateCut, TCut sidebandCut, TCut mcSignalCut, Double_t backgroundShift, Double_t purityBinVal) { dtree_ = dataTree; mtree_ = mcTree; dCut_ = dataCandidateCut; sCut_ = sidebandCut; mCut_ = mcSignalCut; bkg_shift_ = backgroundShift; purityBinVal_ = purityBinVal; const int bins = 100;//0.001/0.00001; double x[bins]; double y[bins]; for(int i = 0; i < bins; i++) { double shift = -0.0005 + 0.001 * ((double)i/bins); x[i] = shift; y[i] = minimizerPurity(shift); } TGraph *plot = new TGraph(bins,x,y); plot->GetYaxis()->SetTitle("#chi^2/ndf"); plot->GetXaxis()->SetTitle("signal distribution shift"); plot->Draw("AP"); }
TGraph *gr21Dspline_tanB(RooSplineND *spline, RooRealVar &ldu, RooRealVar &lVu, RooRealVar &kuu, int type, double minNLL, double fixcbma) { TGraph *points = new TGraph(); int pcounter = 0; double Vldu, VlVu, Vkuu; // holders for the values for (double th=0.001; th<=10;th+=0.1){ double x = fixcbma; double y = TMath::Tan(th); // x irrelevant in grid search if (type==1)type1(x, y, &Vldu, &VlVu, &Vkuu); if (type==2)type2(x, y, &Vldu, &VlVu, &Vkuu); ldu.setVal(Vldu); lVu.setVal(VlVu); kuu.setVal(Vkuu); val = 2*spline->getVal() - minNLL; points->SetPoint(pcounter,val,y); pcounter++; } points->GetYaxis()->SetTitle("tan(#beta)"); points->GetXaxis()->SetTitle("-2#Delta Log(L)"); return points; }
void draw_axis_lambda(const char *opt = "") { const Int_t nn = 2; Double_t xx[nn] = {LAMBDA_MIN, LAMBDA_MAX}; Double_t yy[nn] = {LAMBDA_INT_MIN, LAMBDA_INT_MAX}; TGraph *ga = new TGraph(nn, xx, yy); ga->SetTitle(Form("Intensity (Lambda) %s", opt)); ga->GetXaxis()->SetTitle("Lambda"); ga->GetYaxis()->SetTitle("Intensity"); ga->Draw("ap"); }
void draw_axis_tof(const char *opt = "") { const Int_t nn = 2; Double_t xx[nn] = {TOF_MIN, TOF_MAX}; Double_t yy[nn] = {TOF_INT_MIN, TOF_INT_MAX}; TGraph *ga = new TGraph(nn, xx, yy); ga->SetTitle(Form("Intensity (TOF) %s", opt)); ga->GetXaxis()->SetTitle("TOF"); ga->GetYaxis()->SetTitle("Intensity"); ga->Draw("ap"); }
void plotter::draw_rhotau(TSpline *rhotau, double tau, TString file_name){ TCanvas *c = new TCanvas("c","",600,600); gPad->SetLeftMargin(0.15); TGaxis::SetMaxDigits(3); double logtau = TMath::Log10(tau); std::vector<double> Xpoint = {logtau}; std::vector<double> Ypoint = {rhotau->Eval(logtau)}; TGraph * point = new TGraph(1, &Xpoint[0], &Ypoint[0]); point->SetTitle(" "); point->GetXaxis()->SetTitle("log #tau"); point->GetYaxis()->SetTitle("#rho(log #tau)"); point->GetYaxis()->SetTitleOffset(1.5); point->GetXaxis()->SetNdivisions(505); point->GetYaxis()->SetNdivisions(505); point->SetMarkerStyle(20); point->SetMarkerSize(1.5); point->SetLineColor(1); point->Draw("AP"); point->GetXaxis()->SetLimits(-4.0, -1.5); double ymin = Ypoint[0]*0.95; double ymax = 1.15; point->GetYaxis()->SetRangeUser(ymin, ymax); point->Draw("AP"); c->Update(); // gPad->SetLogx(); rhotau->SetLineColor(kCyan+2); rhotau->SetLineWidth(2); rhotau->Draw("L SAME"); point->Draw("P SAME"); TLegend *l=new TLegend(0.55,0.65,0.85,0.8); l->SetBorderSize(0); l->SetFillStyle(0); l->AddEntry(point,"final #tau value","pl"); l->AddEntry(rhotau,"#tau scan","l"); l->Draw(); c->SaveAs(directory + file_name + ".pdf"); delete c; }
void plot_times() { TCanvas *c1 = new TCanvas("c1", "c1", 1600, 600); ifstream ifs; ifs.open("time_list.txt"); assert(ifs.is_open()); string line; Int_t month, day, hour, min, sec; vector<Int_t> times; vector<Int_t> count; while(getline(ifs,line)) { if(line[0]=='#') continue; stringstream ss(line); ss >> month >> day >> hour >> min >> sec; TDatime da(2014, month, day, hour, min, sec); times.push_back(da.Convert()); count.push_back(1); } TGraph *gr = new TGraph(times.size(), &(times[0]), &(count[0])); gr->SetMarkerStyle(20); gr->GetXaxis()->SetTimeDisplay(1); gr->GetXaxis()->SetNdivisions(-503); gr->GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M"); gr->GetXaxis()->SetTimeOffset(0,"gmt"); gr->GetYaxis()->SetRangeUser(0.8,1.2); gr->Draw("ap"); }
void readGr() { TGraph *gr = new TGraph("graph.dat");// read txt file TCanvas *c1 = new TCanvas(); gr->SetLineColor(2); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); gr->SetTitle("Draw graph from ASCII file"); gr->GetXaxis()->SetTitle("X title"); gr->GetYaxis()->SetTitle("Y title"); gr->Draw("LAP"); //A -> Axis P->Point L->Line(Default) }
// make graph from vectors TGraph *LoadGraphFromVectors(std::vector< double > xVector, std::vector< double > yVector) { int size = xVector.size(); if(xVector.size()== yVector.size()) { //Create a graph TGraph *gr = new TGraph(size, &xVector[0], &yVector[0]); gr->SetTitle(""); gr->SetMarkerStyle(20); gr->SetMarkerSize(1.2); gr->SetLineWidth(2); gr->GetXaxis()->SetTitle("X axis [Arbitrary Units]"); gr->GetXaxis()->CenterTitle(); gr->GetYaxis()->SetTitle("Y axis [Arbitrary Units]"); gr->GetYaxis()->CenterTitle(); return gr; } else { return null; } }
//______________________________________________________________________________ void Draw(TFile* f, const char* gname, TLegend* l, Bool_t normalized) { if (!f) return; TGraph* g = static_cast<TGraph*>(f->Get(gname)); if (!g) return; if ( normalized ) { g = static_cast<TGraph*>(g->Clone()); for ( Int_t i = 0; i < g->GetN(); ++i ) { Double_t y = g->GetY()[i]; g->SetPoint(i,g->GetX()[i],y/NTOTALNUMBEROFPADS); } } g->Draw("lp"); g->GetXaxis()->SetNdivisions(505); g->GetXaxis()->SetNoExponent(); if (l) l->AddEntry(g,gname,"LP"); }
TGraph *MakeGraph(int Type, double fn) { Double_t x[numb], y[numb]; Int_t n = numb; for (Int_t i=0; i<n; i++) { x[i] = i*0.1*1/k; if(Type == 0) y[i] = scalar(&x[i], fn); else if (Type == 1) y[i] = fermion(&x[i], fn); else y[i] = 0; } TGraph *gr = new TGraph(n,x,y); gr->GetXaxis()->SetLimits(1,1000); //gr->GetXaxis()->SetLimits(5,100000); return gr; }
//main of the program void gslSplineDemoV3(double stepSpline =.01) { //initialize data arrays const int nControl=10; double xControl[nControl]= {1,2,3,4,5,6,7,8,9,10}; double yControl[nControl]; int seed = 7898; TRandom3 *jrand = new TRandom3(seed); jrand->RndmArray(nControl,yControl); // make a random array //initialize the spline gsl_interp_accel *acc = gsl_interp_accel_alloc (); gsl_spline *spline = gsl_spline_alloc (gsl_interp_cspline, nControl); //compute the spline gsl_spline_init (spline, xControl, yControl, nControl); //evaluate the spline int nSpline = int((xControl[nControl-1]-xControl[0])/stepSpline); double xSpline[nSpline], ySpline[nSpline]; for (int i= 0; i < nSpline; i++) { xSpline[i] = xControl[0]+i*stepSpline; ySpline[i] = gsl_spline_eval (spline, xSpline[i], acc); } //clear the spline gsl_spline_free (spline); gsl_interp_accel_free (acc); //load the graphs TGraph *grControlPoints = new TGraph(nControl,xControl,yControl); grControlPoints->SetMarkerStyle(20); TGraph *grSpline = new TGraph(nSpline,xSpline,ySpline); grSpline->SetTitle(""); grSpline->GetXaxis()->SetTitle("X-axis [A.U.]"); grSpline->GetYaxis()->SetTitle("Y-axis [A.U.]"); //plot TCanvas *c1 = new TCanvas("c1", "Graph", 200, 10, 700, 500); c1->cd(); grSpline->Draw("al"); grControlPoints->Draw("same p"); }
void quick() { //setTDRStyle(); TCanvas *canv = MakeCanvas("canv", "histograms", 800, 600); canv->cd(); double eff_points[10] = { 0.55, 0.57, 0.59, 0.61, 0.63, 0.65, 0.67, 0.69, 0.71, 0.73 }; double eff_points_2[10] = { 0.55, 0.57, 0.59, 0.61, 0.63, 0.65, 0.67, 0.69, 0.71, 0.73 }; double sig_up[10] = { 1.22484, 1.20737, 1.19085, 1.17521, 1.16035, 1.14622, 1.13276, 1.11993, 1.10767, 1.09593 }; TF1 *fxn = new TF1("fxn", "[0]*TMath::Sqrt([1]*x+[2])/([3]*x+[4])", 0.4, 0.9); fxn->SetParameter(0,114.622/10.7759); fxn->SetParameter(1,11548); fxn->SetParameter(2,658); fxn->SetParameter(3,12.9); fxn->SetParameter(4,0); for (Int_t i=0; i<10; i++) { sig_up[i]*=100; eff_points_2[i]/=0.65; } TGraph *gr = new TGraph(10, eff_points, sig_up); //TGraphAsymmErrors gr2(10, eff_points, sig_cent, 0, 0, sig_down, sig_up); gr->SetLineColor(kRed); //gr->SetLineWidth(2); fxn->SetLineColor(kBlue); //fxn->SetLineWidth(2); //gr2->SetFillColor(kGreen); gr->GetXaxis()->SetTitle("Hadronic #tau Efficiency"); gr->GetYaxis()->SetTitle("Uncertainty on #sigma_{HH}"); gr->Draw("alp"); cout << fxn->Eval(0.65) << endl; fxn->Draw("same R"); }
TGraph *roc(TH1F* iH0,TH1F *iH1,bool iSames=false) { int lN = iH0->GetNbinsX(); double *lX = new double[lN]; double *lY = new double[lN]; bool lFirst = true; for(int i0 = 1; i0 < iH0->GetNbinsX()+1; i0++) { lX[i0-1] = (iH0->Integral(lN-i0,1e9))/iH0->Integral(0,1e9); lY[i0-1] = (iH1->Integral(lN-i0,1e9))/iH1->Integral(0,1e9); if(lY[i0-1] > 0.85 && lFirst) {cout << "---> Back at 85% : " << lX[i0-1] << endl; lFirst = false;} } TGraph *lGraph = new TGraph(lN,lX,lY); lGraph->SetLineColor(kRed); lGraph->SetLineWidth(3); if(iSames) lGraph->SetLineColor(kBlue); lGraph->SetTitle(""); lGraph->GetXaxis()->SetTitle("#epsilon_{back}"); lGraph->GetYaxis()->SetTitle("#epsilon_{sig}"); if(!iSames) lGraph->Draw("al"); if(iSames) lGraph->Draw("l"); }
void QAnalysis::PlotResistance() { TTree* tree = ReadTree(file); TGraph* gr = new TGraph(); int cnt = 0; for (int i=0; i<tree->GetEntries(); i++) { tree->GetEntry(i); if ( posID[0]==1 && posID[1]==1 && posID[2]==18 ) { gr->SetPoint(cnt, time, R); cnt += 1; } } gr->GetXaxis()->SetLabelSize(0); gr->SetTitle("; ; Resistance [#Omega]"); gr->SetLineWidth(2); gr->SetLineColor(kRed); gr->Draw("al"); }
void TDSPMultiEcho::Draw(Option_t *o, Double_t x0, Double_t x1, UInt_t num) { TString opt = o; opt.ToLower(); Ssiz_t pos; if ((pos = opt.Index("multi"))!= kNPOS) { opt.Remove(pos,5); TMultiGraph *m = MultiGraph(NULL,x0,x1,num); m->Draw(o); m->GetXaxis()->SetTitle("#tau / #mu s"); gPad->Update(); return; } TGraph *a = Graph(NULL,x0,x1,num); a->Draw(o); a->GetXaxis()->SetTitle("#tau / #mu s"); gPad->Update(); }
double LeakageCurrentPlot() { ifstream leakfile("scripts/t-v-i.dat"); double x[29], y[29]; int cnt; for(int i=0; i<29; i++) { leakfile>>x[i]>>y[i]; } c = new TCanvas("canv","",600,400); c->SetLogy(); /*Pretty plot*/ gPad->SetLeftMargin(0.15); gPad->SetBottomMargin(0.15); gPad->SetTopMargin(0.05); gPad->SetRightMargin(0.05); TGraph* g = new TGraph(29,x,y); g->SetMarkerStyle(20); g->SetTitle(""); ax = g->GetXaxis(); ax->SetTitle("Detector temperature (K)"); ax->CenterTitle(); ax->SetTitleOffset(1.1); ax->SetTitleSize(0.07); ax->SetLabelSize(0.07); ax->SetTitleFont(132); ax->SetLabelFont(132); ax->SetNdivisions(8,true); ax = g->GetYaxis(); ax->SetRangeUser(1.e-3,1e2); ax->SetTitle("Leakage current (nA)"); ax->CenterTitle(); ax->SetTitleOffset(0.95); ax->SetTitleSize(0.07); ax->SetLabelSize(0.07); ax->SetTitleFont(132); ax->SetLabelFont(132); ax->SetNdivisions(5,true); g->Draw("AP"); }
void QAnalysis::PlotCurrent() { TTree* tree = ReadTree(file); TGraph* gr = new TGraph(); int z = 1; int phi = 1; int r = 18; int cnt = 0; for (int i=0; i<tree->GetEntries(); i++) { tree->GetEntry(i); if ( posID[0]==z && posID[1]==phi && posID[2]==r ) { gr->SetPoint(cnt, time, current); cnt += 1; } } gr->GetXaxis()->SetLabelSize(0); gr->SetTitle("; ; Current [A]"); gr->SetLineColor(kAzure+3); gr->SetLineWidth(2); gr->Draw("al"); }
void plotter::good_bad(vector<double> &vecx, vector<double> &best_gen, vector<double> &smeared_gen, string filename, string title, string xaxis_label) { cout << "scattering plot" << endl; int n = vecx.size(); double arrx[n]; double arry[n]; for (int i=0; i<n; i++){ //arrx[i] = log10(vecx.at(i)+1e-20); arrx[i] = vecx.at(i); double dif = abs(best_gen.at(i)) - abs(smeared_gen.at(i)); arry[i] = dif; } cout << "created arrs" << endl; TCanvas* canvas = new TCanvas("canvas"); TGraph *g = new TGraph(n, arrx, arry); g->SetMarkerStyle(2); cout << "getting axes" << endl; g->Draw("ap"); g->GetXaxis()->SetTitle(xaxis_label.c_str()); g->GetYaxis()->SetTitle("abs(best_gen) - abs(smeared_gen)"); //g->GetXaxis()->SetRangeUser(0,1); //g->GetYaxis()->SetRangeUser(0,20000); g->SetTitle((title).c_str()); canvas->Update(); TLine *l = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0); l->SetLineColor(kBlue); l->Draw(); cout << "before draw" << endl; //g->Draw("ap"); canvas->Update(); cout << "after draw" << endl; canvas->Print(filename.c_str()); cout << "after print" << endl; }
void drawHistoTracker(TH1F* histo, const TString option, const unsigned int color, vector<vector<HistoHolder> > & histos) { // +1 because the array returned by the histogram starts from the underflow bin Float_t * summedValues = histo->GetArray()+1; unsigned int size = histo->GetNbinsX(); double * summedValuesArray = duplicateForGraph(size, summedValues); TGraph * graph = new TGraph(histos[0][0].getSize(1, 0), histos[0][0].time(1, 0), summedValuesArray); graph->Draw(option); graph->SetLineColor(color); graph->GetXaxis()->SetTimeDisplay(1); graph->GetXaxis()->SetLabelOffset(0.02); graph->GetXaxis()->SetTimeFormat("#splitline{ %d}{%H:%M}"); graph->GetXaxis()->SetTimeOffset(0,"gmt"); graph->GetYaxis()->SetRangeUser(0,16000); graph->GetXaxis()->SetTitle("day/hour"); graph->GetXaxis()->SetTitleSize(0.03); graph->GetXaxis()->SetTitleColor(kBlack); graph->GetXaxis()->SetTitleOffset(1.80); graph->GetYaxis()->SetTitle("number of modules off"); graph->GetYaxis()->SetTitleSize(0.03); graph->GetYaxis()->SetTitleColor(kBlack); graph->GetYaxis()->SetTitleOffset(1.80); graph->SetTitle(); }
/* Read data from FILE, which has HEADER_SIZE header lines * before data text and NUM_POINTS total data points. Make a * TGraph titled TITLE, x-axis labeled XTITLE, y-axis labeled * YTITLE. */ void SimpleGraph(char file[] = "", int header_size = 4, int num_points = 30, char title[] = "Graph", char xtitle[] = "wavelength [nm]", char ytitle[] = "Intensity [photons/sec]") { TGraph* plot = new TGraph(); FILE *data = fopen(file, "r"); if (!data) { printf("Options: \"filename\", header size, num points, \"title\", \"x-axis label\", \"y-axis label\".\n"); return; } char line[LINE_SIZE]; char* p; int index = 0; for (int h = 0; h < header_size; h++) fgets(line, sizeof(line), data); while(fgets(line, sizeof(line), data)) { strtok(line, "\n"); if (index > num_points) break; double x = strtod(line, &p); double y = atof(p); plot->SetPoint(index, x, y); index++; } fclose(data); plot->SetTitle(title); plot->GetXaxis()->SetTitle(xtitle); plot->GetYaxis()->SetTitle(ytitle); plot->GetYaxis()->SetTitleOffset(1.5); plot->SetMarkerColor(4); plot->SetMarkerStyle(20); plot->SetMarkerSize(.7); plot->Draw(); }
void entropyFromGinLM(){ ifstream ifile; ifile.open("logisticMapEntropyFromG.txt"); double val; double g=3.5; int pointNumber=0; TGraph *graph = new TGraph(); while(ifile>>val){ graph->SetPoint(pointNumber, g, val); g+=0.0005; pointNumber++; } ifile.close(); graph->SetTitle("Entropia(g)"); graph->GetXaxis()->SetTitle("g"); graph->GetYaxis()->SetTitle("Entropia"); TCanvas *c1 = new TCanvas("c1","Lab1",10,10,800,800); c1->Divide(1,1); c1->cd(1); graph->Draw(); }