Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hist037_TH2Poly_boxes.C File Reference

Detailed Description

View in nbviewer Open in SWAN
This tutorial illustrates how to create an histogram with polygonal bins (TH2Poly).

The bins are boxes.

{
TCanvas *ch2p2 = new TCanvas("ch2p2", "ch2p2", 600, 400);
TH2Poly *h2p = new TH2Poly();
h2p->SetName("Boxes");
h2p->SetTitle("Boxes");
Int_t i, j;
Int_t nx = 40;
Int_t ny = 40;
Double_t dx = 0.2, dy = 0.1;
xval1 = 0.;
xval2 = dx;
for (i = 0; i < nx; i++) {
yval1 = 0.;
yval2 = dy;
for (j = 0; j < ny; j++) {
h2p->AddBin(xval1, yval1, xval2, yval2);
}
}
for (i = 0; i < 300000; i++) {
h2p->Fill(50 * ran.Gaus(2., 1), ran.Gaus(2., 1));
}
h2p->Draw("COLZ");
return ch2p2;
}
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
The Canvas class.
Definition TCanvas.h:23
2D Histogram with Polygonal Bins
Definition TH2Poly.h:66
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1890
Date
August 2016
Author
Olivier Couet

Definition in file hist037_TH2Poly_boxes.C.