{ TCanvas *c1 = new TCanvas("c1", "c1",0,0,600,600); c1->SetTheta(90.); c1->SetPhi(0.0001); gStyle->SetPalette(1); TGraph2D *graph2d = new TGraph2D(); graph2d->SetPoint(0, 110, 110, 0.0); graph2d->SetPoint(1, -80, 50, 1.0); graph2d->SetPoint(2, -70, 40, 2.0); graph2d->SetPoint(3,-110, -50, 3.0); graph2d->SetNpx(9); graph2d->SetNpy(9); graph2d->Draw("surf1"); graph2d->SetLineWidth(2); graph2d->Draw(" triw p0 same"); }
{ double *x = new double[2]; double *y = new double[2]; double *z = new double[2]; x[0] = 6215.; x[1] = 5542.; y[0] = 3853.; y[1] = 5270.; z[0] = 2723.; z[1] = 2723.; TGraph2D * g = new TGraph2D(2, x, y, z); g->Draw("LINE"); }
{ int n = 70; TH1F h("h","test",n,0.,30.); TRandom3 rndm_engine; for (int i=0; i<10000; ++i) h->Fill(rndm_engine->Gaus(15.,4.)); TF1 f("f","gaus"); h->Fit("f"); gPad->SetLogx(); }
{ double yarr[] = { 1.0, 2.0, 3.0, 4.0 }; double xarr[] = { 0.01, 0.02, 0.03, 0.04 }; TH2D *h = new TH2D("h","h",3,xarr,3,yarr); h->Fill(0.011,2.5); h->Draw("box"); }
{ gStyle->SetHistMinimumZero(); TH1F* h = new TH1F("h","h", 44, -0.5, 43.5); h->SetBarWidth(0.7); h->SetBarOffset(0.2); h->SetFillColor(kGreen); for (int i=0;i<44; i++ ) h->Fill(i, -i-60); h->DrawCopy("bar1"); }
{ TCanvas *c02 = new TCanvas("c02","c02",700,400); c02->Divide(2,1); TProfile *profile = new TProfile("profile","profile",10,0,10); profile->SetMarkerSize(2.2); profile->Fill(0.5,1); profile->Fill(1.5,2); profile->Fill(2.5,3); profile->Fill(3.5,4); profile->Fill(4.5,5); profile->Fill(5.5,5); profile->Fill(6.5,4); profile->Fill(7.5,3); profile->Fill(8.5,2); profile->Fill(9.5,1); c02->cd(1); profile->Draw("HIST TEXT0"); c02->cd(2); profile->Draw("HIST TEXT0E"); }
gStyle->SetStatFont(43); gStyle->SetStatFontSize(12); TH2D *h2 = new TH2D("h2","h2",10,0,1,10,0,1); h2->Draw();
TF1 *f = new TF1("f","exp(-x)*exp(x-2.)",0.,2.0); f->Draw();
{ TCanvas *c1 = new TCanvas("c1","c1",200,10,700,500); const Int_t n = 10; Double_t x[n] = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95}; Double_t y[n] = {1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1}; Double_t ex[n] = {.05,.1,.07,.07,10.04,.05,.06,.07,.08,.05}; Double_t ey[n] = {3.8,.7,.6,.5,.4,.4,.5,.6,.7,.8}; Double_t exd[n] = {.0,.0,.0,.0,.0,.0,.0,.0,.0,.0}; Double_t eyd[n] = {.0,.0,.05,.0,.0,.0,.0,.0,.0,.0}; TGraphErrors *gr1 = new TGraphErrors(n,x,y,ex,ey); gr1->SetFillStyle(3004); TGraphAsymmErrors *gr2 = new TGraphAsymmErrors(n, x, y, ex, ex, ey, ey); gr2->SetFillStyle(3005); TGraphBentErrors *gr3 = new TGraphBentErrors(n,x,y,ex,ex,ey,ey,exd,exd,eyd,eyd); gr3->SetFillStyle(3006); c1->DrawFrame(-1,0,1,10); gr1->Draw("2"); gr2->Draw("2"); gr3->Draw("2"); }
{ gStyle->SetHistMinimumZero(); TH1F* h = new TH1F("h","h", 44, -0.5, 43.5); h->SetBarWidth(0.7); h->SetBarOffset(0.2); h->SetFillColor(kGreen); for (int i=0;i<44; i++ ) h->Fill(i, -i-60); h->DrawCopy("b"); }
{ TGraph *graph = new TGraph (); graph->SetPoint(0, 0.00100, 30.00); graph->SetPoint(1, 0.00150, 20.00); graph->SetPoint(2, 0.01150, 30.00); graph->Draw("AL*"); graph->GetXaxis()->SetTitle("foo") ; gPad->SetLogx(1) ; }
root [0] TF1 f1( "f1", "-x", 1,3) root [1] f1.Draw()now selecting some range on the y-axis with the mouse jumped to the range (0, 1) instead of chosen range.