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

Detailed Description

View in nbviewer Open in SWAN
Drawing stack histograms on subpads.

In this example three histograms are displayed on separate pads. If canvas divided in advance - provided subpads will be used by the THStack.

void hstackpads()
{
auto hs = new THStack("hs", "Stacked 1D histograms");
// Create three 1-d histograms and add them in the stack
auto h1st = new TH1F("h1st", "test hstack 1", 100, -4, 4);
h1st->FillRandom("gaus", 20000);
hs->Add(h1st);
auto h2st = new TH1F("h2st", "test hstack 2", 100, -4, 4);
h2st->FillRandom("gaus", 15000);
hs->Add(h2st);
auto h3st = new TH1F("h3st", "test hstack 3", 100, -4, 4);
h3st->FillRandom("gaus", 10000);
hs->Add(h3st);
auto c1 = new TCanvas("c1", "THStack drawing on pads", 800, 800);
// prepare subpads for drawing of histograms
c1->Divide(1, 3);
// draw thstack on canvas with "pads" draw option
c1->Add(hs, "pads");
}
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
Author
Sergey Linev

Definition in file hstackpads.C.