Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
th2polyHoneycomb.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_hist
3/// \notebook -js
4/// This tutorial illustrates how to create an histogram with hexagonal
5/// bins (TH2Poly). The method TH2Poly::Honeycomb allows to build automatically
6/// an honeycomb binning.
7///
8/// \macro_code
9/// \macro_image
10///
11/// \author Olivier Couet
12
13void th2polyHoneycomb(){
14 TCanvas *C = new TCanvas("C", "C", 1200, 600);
15 C->Divide(2,1);
16
17 TH2Poly *hc1 = new TH2Poly();
18 hc1->Honeycomb(0, 0, .1, 5, 5);
19 hc1->SetTitle("Option V (default)");
20 hc1->SetStats(0);
21 hc1->Fill(.1, .1, 15.);
22 hc1->Fill(.4, .4, 10.);
23 hc1->Fill(.5, .5, 20.);
24
25 TH2Poly *hc2 = new TH2Poly();
26 hc2->Honeycomb(0, 0, .1, 5, 5, "h");
27 hc2->SetTitle("Option H");
28 hc2->SetStats(0);
29 hc2->Fill(.1, .1, 15.);
30 hc2->Fill(.4, .4, 10.);
31 hc2->Fill(.5, .5, 20.);
32
33 C->cd(1)->SetGrid();
34 hc1->Draw("colz L");
35 C->cd(2)->SetGrid();
36 hc2->Draw("colz L");
37}
The Canvas class.
Definition TCanvas.h:23
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6709
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3066
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:8981
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:653
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:1015
constexpr Double_t C()
Velocity of light in .
Definition TMath.h:114