Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
accessiblecolorschemes.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphics
3/// \notebook
4/// Choosing an appropriate color scheme is essential for making results easy to understand and
5/// interpret. Factors like colorblindness and converting colors to grayscale for publications
6/// can impact accessibility. Furthermore, results should be aesthetically pleasing. The following
7/// three color schemes, recommended by M. Petroff in [arXiv:2107.02270v2](https://arxiv.org/pdf/2107.02270)
8/// and available on [GitHub](https://github.com/mpetroff/accessible-color-cycles)
9/// under the MIT License, meet these criteria.
10///
11/// \macro_image
12/// \macro_code
13///
14/// \author Olivier Couet
15
16void box(double x1, double y1, double x2, double y2,int col) {
17 auto b1 = new TBox(x1, y1, x2, y2);
18 b1->SetFillColor(col);
19 b1->Draw();
20
21 TColor *c = gROOT->GetColor(col);
22 auto tc = new TLatex((x2+x1)/2., 0.01+(y2+y1)/2., Form("#splitline{%s}{%s}",c->GetName(),c->GetTitle()));
23 tc->SetTextFont(42);
24 tc->SetTextAlign(23);
25 tc->SetTextSize(0.020);
26 tc->Draw();
27}
28
30 auto C = new TCanvas("C","C",600,800);
31 int c;
32 double x, y;
33 double w = 0.2;
34 double h = 0.08;
35 auto t = new TText();
36 t->SetTextSize(0.025);
37 t->SetTextFont(42);
38
39 // 6-colors scheme
40 x = 0.1;
41 y = 0.1;
42 t->DrawText(x, y-h/2., "6-colors scheme");
43 for (c=kP6Blue; c<kP6Blue+6; c++) {
44 box(x, y, x+w, y+h,c);
45 y = y+h;
46 }
47
48 // 8-color scheme
49 y = 0.1;
50 x = 0.4;
51 t->DrawText(x, y-h/2., "8-colors scheme");
52 for (c=kP8Blue; c<kP8Blue+8; c++) {
53 box(x, y, x+w, y+h,c);
54 y = y+h;
55 }
56
57 // 10-color scheme
58 y = 0.1;
59 x = 0.7;
60 t->DrawText(x, y-h/2., "10-colors scheme");
61 for (c=kP10Blue; c<kP10Blue+10; c++) {
62 box(x, y, x+w, y+h,c);
63 y = y+h;
64 }
65}
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
@ kP8Blue
Definition Rtypes.h:70
@ kP10Blue
Definition Rtypes.h:71
@ kP6Blue
Definition Rtypes.h:69
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
#define gROOT
Definition TROOT.h:406
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
Create a Box.
Definition TBox.h:22
The Canvas class.
Definition TCanvas.h:23
The color creation and management class.
Definition TColor.h:21
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1920
To draw Mathematical Formula.
Definition TLatex.h:18
Base class for several text objects.
Definition TText.h:22
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
constexpr Double_t C()
Velocity of light in .
Definition TMath.h:114