{ "cells": [ { "cell_type": "markdown", "id": "d9978790", "metadata": {}, "source": [ "# piechart\n", "\n", "\n", "\n", "\n", "**Author:** Olivier Couet, Guido Volpi \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:37 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "abf7b252", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:21.000626Z", "iopub.status.busy": "2026-05-19T20:37:21.000479Z", "iopub.status.idle": "2026-05-19T20:37:21.465572Z", "shell.execute_reply": "2026-05-19T20:37:21.465103Z" } }, "outputs": [], "source": [ "Float_t vals[] = {.2, 1.1, .6, .9, 2.3};\n", "Int_t colors[] = {2, 3, 4, 5, 6};\n", "Int_t nvals = sizeof(vals) / sizeof(vals[0]);\n", "\n", "TCanvas *cpie = new TCanvas(\"cpie\", \"TPie test\", 700, 700);\n", "cpie->Divide(2, 2);\n", "\n", "TPie *pie1 = new TPie(\"pie1\", \"Pie with offset and no colors\", nvals, vals);\n", "TPie *pie2 = new TPie(\"pie2\", \"Pie with radial labels\", nvals, vals, colors);\n", "TPie *pie3 = new TPie(\"pie3\", \"Pie with tangential labels\", nvals, vals, colors);\n", "TPie *pie4 = new TPie(\"pie4\", \"Pie with verbose labels\", nvals, vals, colors);\n", "\n", "cpie->cd(1);\n", "pie1->SetAngularOffset(30.);\n", "pie1->SetEntryRadiusOffset(4, 0.1);\n", "pie1->SetRadius(.35);\n", "pie1->Draw(\"3d\");\n", "\n", "cpie->cd(2);\n", "pie2->SetEntryRadiusOffset(2, .05);\n", "pie2->SetEntryLineColor(2, 2);\n", "pie2->SetEntryLineWidth(2, 5);\n", "pie2->SetEntryLineStyle(2, 2);\n", "pie2->SetEntryFillStyle(1, 3030);\n", "pie2->SetCircle(.5, .45, .3);\n", "pie2->Draw(\"rsc\");\n", "\n", "cpie->cd(3);\n", "pie3->SetY(.32);\n", "pie3->GetSlice(0)->SetValue(.8);\n", "pie3->GetSlice(1)->SetFillStyle(3031);\n", "pie3->SetLabelsOffset(-.1);\n", "pie3->Draw(\"3d t nol\");\n", "TLegend *pieleg = pie3->MakeLegend();\n", "pieleg->SetY1(.56);\n", "pieleg->SetY2(.86);\n", "\n", "cpie->cd(4);\n", "pie4->SetRadius(.2);\n", "pie4->SetLabelsOffset(.01);\n", "pie4->SetLabelFormat(\"#splitline{%val (%perc)}{%txt}\");\n", "pie4->Draw(\"nol <\");" ] }, { "cell_type": "markdown", "id": "4e0e4808", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "bf9c9850", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:21.467385Z", "iopub.status.busy": "2026-05-19T20:37:21.467273Z", "iopub.status.idle": "2026-05-19T20:37:21.676871Z", "shell.execute_reply": "2026-05-19T20:37:21.676392Z" } }, "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 }