{ "cells": [ { "cell_type": "markdown", "id": "6b54c6d0", "metadata": {}, "source": [ "# hist051_Graphics_candle_plot_stack\n", "\n", "\n", "\n", "\n", "**Author:** Georg Troska, Olivier Couet \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:13 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "aa2e36bf", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:13:04.618285Z", "iopub.status.busy": "2026-05-19T20:13:04.618148Z", "iopub.status.idle": "2026-05-19T20:13:05.215508Z", "shell.execute_reply": "2026-05-19T20:13:05.214913Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gStyle->SetTimeOffset(0);\n", "auto rng = new TRandom();\n", "auto dateBegin = new TDatime(2010, 1, 1, 0, 0, 0);\n", "auto dateEnd = new TDatime(2011, 1, 1, 0, 0, 0);\n", "int bins = 1000;\n", "auto h1 = new TH2I(\"h1\", \"Machine A\", 6, dateBegin->Convert(), dateEnd->Convert(), bins, 0, 1000);\n", "auto h2 = new TH2I(\"h2\", \"Machine B\", 6, dateBegin->Convert(), dateEnd->Convert(), bins, 0, 1000);\n", "auto hsum = new TH2I(\"h4\", \"Sum\", 6, dateBegin->Convert(), dateEnd->Convert(), bins, 0, 1000);\n", "\n", "float Rand;\n", "for (int i = dateBegin->Convert(); i < dateEnd->Convert(); i += 86400 * 30) {\n", " for (int j = 0; j < 1000; j++) {\n", " Rand = rng->Gaus(500 + sin(i / 10000000.) * 100, 50);\n", " h1->Fill(i, Rand);\n", " hsum->Fill(i, Rand);\n", " Rand = rng->Gaus(500 + sin(i / 12000000.) * 100, 50);\n", " h2->Fill(i, Rand);\n", " hsum->Fill(i, Rand);\n", " }\n", "}\n", "\n", "h2->SetLineColor(kRed);\n", "hsum->SetFillColor(kGreen);\n", "TCanvas *c1 = new TCanvas();\n", "\n", "auto hs = new THStack(\"hs\", \"Machine A+B\");\n", "hs->Add(h1);\n", "hs->Add(h2, \"candle2\");\n", "hs->Add(hsum, \"violin1\");\n", "hs->Draw(\"candle3\");\n", "hs->GetXaxis()->SetNdivisions(410);\n", "\n", "gPad->SetGrid(1, 0);\n", "\n", "hs->GetXaxis()->SetTimeDisplay(1);\n", "hs->GetXaxis()->SetTimeFormat(\"%d/%m/%y\");\n", "hs->GetXaxis()->SetNdivisions(-6);\n", "hs->GetXaxis()->SetTitle(\"Date [day/month/year]\");\n", "c1->Modified();\n", "\n", "gPad->BuildLegend(0.75, 0.75, 0.95, 0.95, \"\");" ] }, { "cell_type": "markdown", "id": "0302df27", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "d62c5a6f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:13:05.221336Z", "iopub.status.busy": "2026-05-19T20:13:05.221200Z", "iopub.status.idle": "2026-05-19T20:13:05.425258Z", "shell.execute_reply": "2026-05-19T20:13:05.424863Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gROOT->GetListOfCanvases()->Draw()" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }