{ "cells": [ { "cell_type": "markdown", "id": "7770bd9c", "metadata": {}, "source": [ "# palettes\n", "It generates a png file for each palette and one pdf file, with a table of\n", "content, containing all the palettes.\n", "\n", "In ROOT, [more than 60 high quality palettes are predefined with 255 colors\n", "each](https://root.cern/doc/master/classTColor.html#C06).\n", "\n", "These palettes can be accessed \"by name\" with `gStyle->SetPalette(num)`. num\n", "can be taken within the enum given in the previous link. As an example\n", "`gStyle->SetPalette(kCividis)` will select the following palette.\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:37 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "6d24bf2a", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:20.013340Z", "iopub.status.busy": "2026-05-19T20:37:20.013199Z", "iopub.status.idle": "2026-05-19T20:37:20.378407Z", "shell.execute_reply": "2026-05-19T20:37:20.377703Z" } }, "outputs": [], "source": [ "TCanvas *c = nullptr;" ] }, { "cell_type": "markdown", "id": "836a3c9f", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 2, "id": "cf09c959", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:20.381346Z", "iopub.status.busy": "2026-05-19T20:37:20.381214Z", "iopub.status.idle": "2026-05-19T20:37:20.401101Z", "shell.execute_reply": "2026-05-19T20:37:20.400377Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "void draw_palette(int p, TString n)\n", "{\n", " delete c;\n", " c = new TCanvas(\"c\", \"Contours\", 0, 0, 500, 500);\n", " TF2 *f2 = new TF2(\"f2\", \"0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))\", 0.999, 3.002, 0.999, 3.002);\n", " f2->SetContour(99);\n", " gStyle->SetPalette(p);\n", " f2->SetLineWidth(1);\n", " f2->SetLineColor(kBlack);\n", " f2->Draw(\"surf1z\");\n", "\n", " // Title\n", " TPaveText *pt = new TPaveText(10, 11, 10, 11, \"blNDC\");\n", " pt->SetName(\"title\");\n", " pt->Draw();\n", " TString num = n;\n", " num.ReplaceAll(\" \", \"\");\n", " TLatex *l = new TLatex(-0.8704441, 0.9779387,\n", " TString::Format(\"Palette #%d: %s #scale[0.7]{(#font[82]{k%s})}\", p, n.Data(), num.Data()));\n", " l->SetTextFont(42);\n", " l->SetTextSize(0.035);\n", " l->Draw();\n", " c->Update();\n", " c->Print(TString::Format(\"palette_%d.png\", p));\n", "\n", " TString opt = TString(\"Title:\") + n;\n", " if (p == kDeepSea)\n", " c->Print(\"palettes.pdf(\", opt.Data());\n", " else if (p == kCividis)\n", " c->Print(\"palettes.pdf)\", opt.Data());\n", " else\n", " c->Print(\"palettes.pdf\", opt.Data());\n", "}" ] }, { "cell_type": "code", "execution_count": 3, "id": "cf88aa7d", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:20.402710Z", "iopub.status.busy": "2026-05-19T20:37:20.402559Z", "iopub.status.idle": "2026-05-19T20:37:28.588356Z", "shell.execute_reply": "2026-05-19T20:37:28.587846Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "Info in : png file palette_51.png has been created\n", "Info in : pdf file palettes.pdf has been created using the current canvas\n", "Info in : png file palette_52.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_53.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_54.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_55.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_56.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_57.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_58.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_59.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_60.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_61.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_62.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_63.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_64.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_65.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_66.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_67.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_68.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_69.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_70.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_71.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_72.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_73.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_74.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_75.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_76.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_77.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_78.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_79.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_80.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_81.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_82.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_83.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_84.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_85.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_86.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_87.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_88.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_89.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_90.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_91.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_92.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_93.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_94.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_95.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_96.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_97.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_98.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_99.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_100.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_101.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_102.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_103.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_104.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_105.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_106.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_107.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_108.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_109.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_110.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_111.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_112.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf\n", "Info in : png file palette_113.png has been created\n", "Info in : Current canvas added to pdf file palettes.pdf and file closed\n" ] } ], "source": [ "gROOT->SetBatch(1);\n", "draw_palette(kDeepSea, \"Deap Sea\");\n", "draw_palette(kGreyScale, \"Grey Scale\");\n", "draw_palette(kDarkBodyRadiator, \"Dark Body Radiator\");\n", "draw_palette(kBlueYellow, \"Blue Yellow\");\n", "draw_palette(kRainBow, \"Rain Bow\");\n", "draw_palette(kInvertedDarkBodyRadiator, \"Inverted Dark Body Radiator\");\n", "draw_palette(kBird, \"Bird\");\n", "draw_palette(kCubehelix, \"Cube helix\");\n", "draw_palette(kGreenRedViolet, \"Green Red Violet\");\n", "draw_palette(kBlueRedYellow, \"Blue Red Yellow\");\n", "draw_palette(kOcean, \"Ocean\");\n", "draw_palette(kColorPrintableOnGrey, \"Color Printable On Grey\");\n", "draw_palette(kAlpine, \"Alpine\");\n", "draw_palette(kAquamarine, \"Aquamarine\");\n", "draw_palette(kArmy, \"Army\");\n", "draw_palette(kAtlantic, \"Atlantic\");\n", "draw_palette(kAurora, \"Aurora\");\n", "draw_palette(kAvocado, \"Avocado\");\n", "draw_palette(kBeach, \"Beach\");\n", "draw_palette(kBlackBody, \"Black Body\");\n", "draw_palette(kBlueGreenYellow, \"Blue Green Yellow\");\n", "draw_palette(kBrownCyan, \"Brown Cyan\");\n", "draw_palette(kCMYK, \"CMYK\");\n", "draw_palette(kCandy, \"Candy\");\n", "draw_palette(kCherry, \"Cherry\");\n", "draw_palette(kCoffee, \"Coffee\");\n", "draw_palette(kDarkRainBow, \"Dark Rain Bow\");\n", "draw_palette(kDarkTerrain, \"Dark Terrain\");\n", "draw_palette(kFall, \"Fall\");\n", "draw_palette(kFruitPunch, \"Fruit Punch\");\n", "draw_palette(kFuchsia, \"Fuchsia\");\n", "draw_palette(kGreyYellow, \"Grey Yellow\");\n", "draw_palette(kGreenBrownTerrain, \"Green Brown Terrain\");\n", "draw_palette(kGreenPink, \"Green Pink\");\n", "draw_palette(kIsland, \"Island\");\n", "draw_palette(kLake, \"Lake\");\n", "draw_palette(kLightTemperature, \"Light Temperature\");\n", "draw_palette(kLightTerrain, \"Light Terrain\");\n", "draw_palette(kMint, \"Mint\");\n", "draw_palette(kNeon, \"Neon\");\n", "draw_palette(kPastel, \"Pastel\");\n", "draw_palette(kPearl, \"Pearl\");\n", "draw_palette(kPigeon, \"Pigeon\");\n", "draw_palette(kPlum, \"Plum\");\n", "draw_palette(kRedBlue, \"Red Blue\");\n", "draw_palette(kRose, \"Rose\");\n", "draw_palette(kRust, \"Rust\");\n", "draw_palette(kSandyTerrain, \"Sandy Terrain\");\n", "draw_palette(kSienna, \"Sienna\");\n", "draw_palette(kSolar, \"Solar\");\n", "draw_palette(kSouthWest, \"South West\");\n", "draw_palette(kStarryNight, \"Starry Night\");\n", "draw_palette(kSunset, \"Sunset\");\n", "draw_palette(kTemperatureMap, \"Temperature Map\");\n", "draw_palette(kThermometer, \"Thermometer\");\n", "draw_palette(kValentine, \"Valentine\");\n", "draw_palette(kVisibleSpectrum, \"Visible Spectrum\");\n", "draw_palette(kWaterMelon, \"Water Melon\");\n", "draw_palette(kCool, \"Cool\");\n", "draw_palette(kCopper, \"Copper\");\n", "draw_palette(kGistEarth, \"Gist Earth\");\n", "draw_palette(kViridis, \"Viridis\");\n", "draw_palette(kCividis, \"Cividis\");" ] }, { "cell_type": "markdown", "id": "9394f8f0", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 4, "id": "a1cc978b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:28.589981Z", "iopub.status.busy": "2026-05-19T20:37:28.589851Z", "iopub.status.idle": "2026-05-19T20:37:28.807347Z", "shell.execute_reply": "2026-05-19T20:37:28.806830Z" } }, "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 }