{ "cells": [ { "cell_type": "markdown", "id": "505f0138", "metadata": {}, "source": [ "# hist036_TH2_labels\n", "\n", "\n", "\n", "\n", "**Author:** Rene Brun \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": "4a3fcf55", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:49.412412Z", "iopub.status.busy": "2026-05-19T20:12:49.412272Z", "iopub.status.idle": "2026-05-19T20:12:49.762472Z", "shell.execute_reply": "2026-05-19T20:12:49.761585Z" } }, "outputs": [], "source": [ "const Int_t nx = 12;\n", "const Int_t ny = 20;\n", "const char *month[nx] = {\"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n", " \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"};\n", "const char *people[ny] = {\"Jean\", \"Pierre\", \"Marie\", \"Odile\", \"Sebastien\", \"Fons\", \"Rene\",\n", " \"Nicolas\", \"Xavier\", \"Greg\", \"Bjarne\", \"Anton\", \"Otto\", \"Eddy\",\n", " \"Peter\", \"Pasha\", \"Philippe\", \"Suzanne\", \"Jeff\", \"Valery\"};\n", "TCanvas *c1 = new TCanvas(\"c1\", \"demo bin labels\", 10, 10, 600, 600);\n", "c1->SetGrid();\n", "c1->SetLeftMargin(0.15);\n", "c1->SetBottomMargin(0.15);\n", "TH2F *h = new TH2F(\"h\", \"test\", 3, 0, 3, 2, 0, 2);\n", "h->SetCanExtend(TH1::kAllAxes);\n", "h->SetStats(0);\n", "gRandom->SetSeed();\n", "for (Int_t i = 0; i < 15000; i++) {\n", " Int_t rx = gRandom->Rndm() * nx;\n", " Int_t ry = gRandom->Rndm() * ny;\n", " h->Fill(people[ry], month[rx], 1);\n", "}\n", "h->LabelsDeflate(\"X\");\n", "h->LabelsDeflate(\"Y\");\n", "h->LabelsOption(\"v\");\n", "h->Draw(\"text\");\n", "\n", "TPaveText *pt = new TPaveText(0.6, 0.85, 0.98, 0.98, \"brNDC\");\n", "pt->SetFillColor(18);\n", "pt->SetTextAlign(12);\n", "pt->AddText(\"Use the axis Context Menu LabelsOption\");\n", "pt->AddText(\" \\\"a\\\" to sort by alphabetic order\");\n", "pt->AddText(\" \\\">\\\" to sort by decreasing values\");\n", "pt->AddText(\" \\\"<\\\" to sort by increasing values\");\n", "pt->Draw();" ] }, { "cell_type": "markdown", "id": "81b07d60", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "a6a1af50", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:49.775456Z", "iopub.status.busy": "2026-05-19T20:12:49.775312Z", "iopub.status.idle": "2026-05-19T20:12:49.979708Z", "shell.execute_reply": "2026-05-19T20:12:49.979202Z" } }, "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 }