{ "cells": [ { "cell_type": "markdown", "id": "2e3af436", "metadata": {}, "source": [ "# accessiblecolorschemes\n", "Factors like colorblindness and converting colors to grayscale for publications\n", "can impact accessibility. Furthermore, results should be aesthetically pleasing. The following\n", "three color schemes, recommended by M. Petroff in [arXiv:2107.02270v2](https://arxiv.org/pdf/2107.02270)\n", "and available on [GitHub](https://github.com/mpetroff/accessible-color-cycles)\n", "under the MIT License, meet these criteria.\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:36 PM." ] }, { "cell_type": "markdown", "id": "1b433485", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 1, "id": "72715de4", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:42.836482Z", "iopub.status.busy": "2026-05-19T20:36:42.836361Z", "iopub.status.idle": "2026-05-19T20:36:42.843837Z", "shell.execute_reply": "2026-05-19T20:36:42.843439Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "\n", "void box(double x1, double y1, double x2, double y2, int col)\n", "{\n", " auto b1 = new TBox(x1, y1, x2, y2);\n", " b1->SetFillColor(col);\n", " b1->Draw();\n", "\n", " TColor *c = gROOT->GetColor(col);\n", " auto tc = new TLatex((x2 + x1) / 2., 0.01 + (y2 + y1) / 2., Form(\"#splitline{%s}{%s}\", c->GetName(), c->GetTitle()));\n", " tc->SetTextFont(42);\n", " tc->SetTextAlign(23);\n", " tc->SetTextSize(0.020);\n", " tc->Draw();\n", "}" ] }, { "cell_type": "code", "execution_count": 2, "id": "005b6466", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:42.845259Z", "iopub.status.busy": "2026-05-19T20:36:42.845140Z", "iopub.status.idle": "2026-05-19T20:36:43.193775Z", "shell.execute_reply": "2026-05-19T20:36:43.193370Z" } }, "outputs": [], "source": [ "auto C = new TCanvas(\"C\", \"C\", 600, 800);\n", "int c;\n", "double x, y;\n", "double w = 0.2;\n", "double h = 0.08;\n", "auto t = new TText();\n", "t->SetTextSize(0.025);\n", "t->SetTextFont(42);" ] }, { "cell_type": "markdown", "id": "b2ef8220", "metadata": {}, "source": [ "6-colors scheme" ] }, { "cell_type": "code", "execution_count": 3, "id": "e417e2d7", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:43.201939Z", "iopub.status.busy": "2026-05-19T20:36:43.201807Z", "iopub.status.idle": "2026-05-19T20:36:43.403770Z", "shell.execute_reply": "2026-05-19T20:36:43.403315Z" } }, "outputs": [], "source": [ "x = 0.1;\n", "y = 0.1;\n", "t->DrawText(x, y - h / 2., \"6-colors scheme\");\n", "for (c = kP6Blue; c < kP6Blue + 6; c++) {\n", " box(x, y, x + w, y + h, c);\n", " y = y + h;\n", "}" ] }, { "cell_type": "markdown", "id": "cdc483fd", "metadata": {}, "source": [ "8-color scheme" ] }, { "cell_type": "code", "execution_count": 4, "id": "4bc704c4", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:43.405901Z", "iopub.status.busy": "2026-05-19T20:36:43.405774Z", "iopub.status.idle": "2026-05-19T20:36:43.607520Z", "shell.execute_reply": "2026-05-19T20:36:43.607153Z" } }, "outputs": [], "source": [ "y = 0.1;\n", "x = 0.4;\n", "t->DrawText(x, y - h / 2., \"8-colors scheme\");\n", "for (c = kP8Blue; c < kP8Blue + 8; c++) {\n", " box(x, y, x + w, y + h, c);\n", " y = y + h;\n", "}" ] }, { "cell_type": "markdown", "id": "7d941060", "metadata": {}, "source": [ "10-color scheme" ] }, { "cell_type": "code", "execution_count": 5, "id": "e9c9d1d5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:43.621300Z", "iopub.status.busy": "2026-05-19T20:36:43.621156Z", "iopub.status.idle": "2026-05-19T20:36:43.834211Z", "shell.execute_reply": "2026-05-19T20:36:43.833649Z" } }, "outputs": [], "source": [ "y = 0.1;\n", "x = 0.7;\n", "t->DrawText(x, y - h / 2., \"10-colors scheme\");\n", "for (c = kP10Blue; c < kP10Blue + 10; c++) {\n", " box(x, y, x + w, y + h, c);\n", " y = y + h;\n", "}" ] }, { "cell_type": "markdown", "id": "10a05bbb", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 6, "id": "473491f7", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:36:43.846172Z", "iopub.status.busy": "2026-05-19T20:36:43.846039Z", "iopub.status.idle": "2026-05-19T20:36:44.077358Z", "shell.execute_reply": "2026-05-19T20:36:44.076680Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "