{ "cells": [ { "cell_type": "markdown", "id": "4eda4e5d", "metadata": {}, "source": [ "# hist022_TH2_palette\n", "vertically on the right side of the plot. It is possible to move and resize this\n", "vertical palette as shown on the left plot. The right plot demonstrates that, when the\n", "width of the palette is larger than its height, the palette is automatically drawn\n", "horizontally.\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": "1ce80c28", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:25.250331Z", "iopub.status.busy": "2026-05-19T20:12:25.250204Z", "iopub.status.idle": "2026-05-19T20:12:25.817580Z", "shell.execute_reply": "2026-05-19T20:12:25.817061Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "auto c = new TCanvas(\"\", \"\", 0, 0, 1100, 550);\n", "c->Divide(2, 1);\n", "gStyle->SetOptStat(0);\n", "\n", "auto h1 = new TH2D(\"h1\", \"h1\", 40, -4, 4, 40, -20, 20);\n", "auto h2 = new TH2D(\"h2\", \"h2\", 40, -4, 4, 40, -20, 20);\n", "float px, py;\n", "for (int i = 0; i < 25000; i++) {\n", " gRandom->Rannor(px, py);\n", " h1->Fill(px, 5 * py);\n", " gRandom->Rannor(px, py);\n", " h2->Fill(px, 5 * py);\n", "}\n", "\n", "TPad *p1 = (TPad *)c->cd(1);\n", "TPad *p2 = (TPad *)c->cd(2);\n", "\n", "p1->SetRightMargin(0.15);\n", "auto palette1 = new TPaletteAxis(4.05, -15, 4.5, 15, h1);\n", "h1->GetListOfFunctions()->Add(palette1);\n", "\n", "p2->SetBottomMargin(0.2);\n", "auto palette2 = new TPaletteAxis(-3., -25, 3., -23, h2);\n", "h2->GetListOfFunctions()->Add(palette2);\n", "\n", "p1->cd();\n", "h1->Draw(\"colz\");\n", "p2->cd();\n", "h2->Draw(\"colz\");" ] }, { "cell_type": "markdown", "id": "c5bc31a2", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "6ffc4ec1", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:25.826179Z", "iopub.status.busy": "2026-05-19T20:12:25.826041Z", "iopub.status.idle": "2026-05-19T20:12:26.030890Z", "shell.execute_reply": "2026-05-19T20:12:26.029666Z" } }, "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 }