11 void candleplotstack()
13 gStyle->SetTimeOffset(0);
14 TRandom *rng =
new TRandom();
15 TDatime *dateBegin =
new TDatime(2010,1,1,0,0,0);
16 TDatime *dateEnd =
new TDatime(2011,1,1,0,0,0);
18 TH2I *h1 =
new TH2I(
"h1",
"Machine A",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
19 TH2I *h2 =
new TH2I(
"h2",
"Machine B",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
20 TH2I *hsum =
new TH2I(
"h4",
"Sum",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
23 for (
int i = dateBegin->Convert(); i < dateEnd->Convert(); i+=86400*30) {
24 for (
int j = 0; j < 1000; j++) {
25 Rand = rng->Gaus(500+sin(i/10000000.)*100,50); h1->Fill(i,Rand); hsum->Fill(i,Rand);
26 Rand = rng->Gaus(500+sin(i/12000000.)*100,50); h2->Fill(i,Rand); hsum->Fill(i,Rand);
30 h2->SetLineColor(kRed);
31 hsum->SetFillColor(kGreen);
32 TCanvas *c1 =
new TCanvas();
34 THStack *hs =
new THStack(
"hs",
"Machine A+B");
36 hs->Add(h2,
"candle2");
37 hs->Add(hsum,
"violin1");
39 hs->GetXaxis()->SetNdivisions(410);
43 hs->GetXaxis()->SetTimeDisplay(1);
44 hs->GetXaxis()->SetTimeFormat(
"%m/%y");
45 hs->GetXaxis()->SetTitle(
"Date [month/year]");
49 gPad->BuildLegend(0.75,0.75,0.95,0.95,
"");