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

Detailed Description

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

The method TH2Poly::Honeycomb allows to build automatically an honeycomb binning.

void hist038_TH2Poly_honeycomb()
{
TCanvas *C = new TCanvas("C", "C", 1200, 600);
C->Divide(2, 1);
TH2Poly *hc1 = new TH2Poly();
hc1->Honeycomb(0, 0, .1, 5, 5);
hc1->SetTitle("Option V (default)");
hc1->SetStats(0);
hc1->Fill(.1, .1, 15.);
hc1->Fill(.4, .4, 10.);
hc1->Fill(.5, .5, 20.);
TH2Poly *hc2 = new TH2Poly();
hc2->Honeycomb(0, 0, .1, 5, 5, "h");
hc2->SetTitle("Option H");
hc2->SetStats(0);
hc2->Fill(.1, .1, 15.);
hc2->Fill(.4, .4, 10.);
hc2->Fill(.5, .5, 20.);
C->cd(1)->SetGrid();
hc1->Draw("colz L");
C->cd(2)->SetGrid();
hc2->Draw("colz L");
}
The Canvas class.
Definition TCanvas.h:23
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6836
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3097
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:9127
2D Histogram with Polygonal Bins
Definition TH2Poly.h:66
Int_t Fill(Double_t x, Double_t y) override
Increment the bin containing (x,y) by 1.
Definition TH2Poly.cxx:650
void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s, Option_t *option="v")
Bins the histogram using a honeycomb structure If the option "v" is specified, the hexagons are drawn...
Definition TH2Poly.cxx:1012
Date
August 2023
Author
Olivier Couet

Definition in file hist038_TH2Poly_honeycomb.C.