ROOT
Version v6.34
master
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
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
16
void
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
29
void
accessiblecolorschemes
() {
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
}
c
#define c(i)
Definition
RSha256.hxx:101
h
#define h(i)
Definition
RSha256.hxx:106
kP8Blue
@ kP8Blue
Definition
Rtypes.h:70
kP10Blue
@ kP10Blue
Definition
Rtypes.h:71
kP6Blue
@ kP6Blue
Definition
Rtypes.h:69
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
w
winID w
Definition
TGWin32VirtualGLProxy.cxx:39
x2
Option_t Option_t TPoint TPoint const char x2
Definition
TGWin32VirtualXProxy.cxx:70
x1
Option_t Option_t TPoint TPoint const char x1
Definition
TGWin32VirtualXProxy.cxx:70
y2
Option_t Option_t TPoint TPoint const char y2
Definition
TGWin32VirtualXProxy.cxx:70
y1
Option_t Option_t TPoint TPoint const char y1
Definition
TGWin32VirtualXProxy.cxx:70
gROOT
#define gROOT
Definition
TROOT.h:406
Form
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition
TString.cxx:2489
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TBox
Create a Box.
Definition
TBox.h:22
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TColor
The color creation and management class.
Definition
TColor.h:21
TColor::GetColor
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
TLatex
To draw Mathematical Formula.
Definition
TLatex.h:18
TText
Base class for several text objects.
Definition
TText.h:22
box
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition
fillpatterns.C:1
y
Double_t y[n]
Definition
legend1.C:17
x
Double_t x[n]
Definition
legend1.C:17
TMath::C
constexpr Double_t C()
Velocity of light in .
Definition
TMath.h:114
tutorials
graphics
accessiblecolorschemes.C
ROOT tags/6-34-04 - Reference Guide Generated on Thu Mar 27 2025 14:48:01 (GVA Time) using Doxygen 1.10.0