{ "cells": [ { "cell_type": "markdown", "id": "ec051155", "metadata": {}, "source": [ "# hist025_THStack_2d_palette_color\n", "(Palette Fill Color).\n", "When this option is given to `THStack::Draw` the histograms in the\n", "`THStack` get their color from the current color palette defined by\n", "`gStyle->SetPalette(...)`. The color is determined according to the number of\n", "histograms.\n", "\n", "In this example four 2D histograms are displayed with palette coloring.\n", "The color of each graph is picked inside the palette number 1.\n", "\n", "\n", "\n", "\n", "**Author:** 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:12 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "a8e0f1c9", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:28.381929Z", "iopub.status.busy": "2026-05-19T20:12:28.381819Z", "iopub.status.idle": "2026-05-19T20:12:28.736623Z", "shell.execute_reply": "2026-05-19T20:12:28.736210Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Info in : created default TCanvas with name c1\n" ] } ], "source": [ "gStyle->SetPalette(1);\n", "auto h1 = new TH2F(\"h1\", \"h1\", 20, 0, 6, 20, -4, 4);\n", "auto h2 = new TH2F(\"h2\", \"h2\", 20, 0, 6, 20, -4, 4);\n", "auto h3 = new TH2F(\"h3\", \"h3\", 20, 0, 6, 20, -4, 4);\n", "auto h4 = new TH2F(\"h4\", \"h4\", 20, 0, 6, 20, -4, 4);\n", "auto h5 = new TH2F(\"h5\", \"h5\", 20, 0, 6, 20, -4, 4);\n", "h2->Fill(2., 0., 5);\n", "h3->Fill(3., 0., 10);\n", "h4->Fill(4., 0., 15);\n", "h5->Fill(5., 0., 20);\n", "auto hs = new THStack(\"hs\", \"Test of palette colored lego stack\");\n", "hs->Add(h1);\n", "hs->Add(h2);\n", "hs->Add(h3);\n", "hs->Add(h4);\n", "hs->Add(h5);\n", "hs->Draw(\"0lego1 PFC\");" ] }, { "cell_type": "markdown", "id": "7488d13a", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "516a1d1a", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:28.737884Z", "iopub.status.busy": "2026-05-19T20:12:28.737773Z", "iopub.status.idle": "2026-05-19T20:12:28.946934Z", "shell.execute_reply": "2026-05-19T20:12:28.946492Z" } }, "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 }