Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hstackpads.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_hist
3/// \notebook
4/// Drawing stack histograms on subpads.
5///
6/// In this example three histograms are displayed on separate pads.
7/// If canvas divided in advance - provided subpads will be used by the THStack.
8///
9/// \macro_image
10/// \macro_code
11///
12/// \author Sergey Linev
13
14void hstackpads()
15{
16 auto hs = new THStack("hs", "Stacked 1D histograms");
17
18 // Create three 1-d histograms and add them in the stack
19 auto h1st = new TH1F("h1st", "test hstack 1", 100, -4, 4);
20 h1st->FillRandom("gaus", 20000);
21 hs->Add(h1st);
22
23 auto h2st = new TH1F("h2st", "test hstack 2", 100, -4, 4);
24 h2st->FillRandom("gaus", 15000);
25 hs->Add(h2st);
26
27 auto h3st = new TH1F("h3st", "test hstack 3", 100, -4, 4);
28 h3st->FillRandom("gaus", 10000);
29 hs->Add(h3st);
30
31 auto c1 = new TCanvas("c1", "THStack drawing on pads", 800, 800);
32
33 // prepare subpads for drawing of histograms
34 c1->Divide(1, 3);
35
36 // draw thstack on canvas with "pads" draw option
37 c1->Add(hs, "pads");
38}
The Canvas class.
Definition TCanvas.h:23
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:623
The Histogram stack class.
Definition THStack.h:40
return c1
Definition legend1.C:41