ROOT
master
Reference Guide
Loading...
Searching...
No Matches
accessiblecolorschemes.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_graphics
3
/// \notebook
4
/// \preview Choosing an appropriate color scheme is essential for making results easy to understand and interpret.
5
/// 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
{
18
auto
b1 =
new
TBox
(
x1
,
y1
,
x2
,
y2
);
19
b1->SetFillColor(col);
20
b1->Draw();
21
22
TColor
*
c
=
gROOT
->
GetColor
(col);
23
auto
tc
=
new
TLatex
((
x2
+
x1
) / 2., 0.01 + (
y2
+
y1
) / 2.,
Form
(
"#splitline{%s}{%s}"
,
c
->GetName(),
c
->GetTitle()));
24
tc
->SetTextFont(42);
25
tc
->SetTextAlign(23);
26
tc
->SetTextSize(0.020);
27
tc
->Draw();
28
}
29
30
void
accessiblecolorschemes
()
31
{
32
auto
C
=
new
TCanvas
(
"C"
,
"C"
, 600, 800);
33
int
c
;
34
double
x
,
y
;
35
double
w
= 0.2;
36
double
h
= 0.08;
37
auto
t =
new
TText
();
38
t->SetTextSize(0.025);
39
t->SetTextFont(42);
40
41
// 6-colors scheme
42
x
= 0.1;
43
y
= 0.1;
44
t->DrawText(
x
,
y
-
h
/ 2.,
"6-colors scheme"
);
45
for
(
c
=
kP6Blue
;
c
<
kP6Blue
+ 6;
c
++) {
46
box
(
x
,
y
,
x
+
w
,
y
+
h
,
c
);
47
y
=
y
+
h
;
48
}
49
50
// 8-color scheme
51
y
= 0.1;
52
x
= 0.4;
53
t->DrawText(
x
,
y
-
h
/ 2.,
"8-colors scheme"
);
54
for
(
c
=
kP8Blue
;
c
<
kP8Blue
+ 8;
c
++) {
55
box
(
x
,
y
,
x
+
w
,
y
+
h
,
c
);
56
y
=
y
+
h
;
57
}
58
59
// 10-color scheme
60
y
= 0.1;
61
x
= 0.7;
62
t->DrawText(
x
,
y
-
h
/ 2.,
"10-colors scheme"
);
63
for
(
c
=
kP10Blue
;
c
<
kP10Blue
+ 10;
c
++) {
64
box
(
x
,
y
,
x
+
w
,
y
+
h
,
c
);
65
y
=
y
+
h
;
66
}
67
}
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:22
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:1927
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
visualisation
graphics
accessiblecolorschemes.C
ROOT master - Reference Guide Generated on Tue Apr 22 2025 16:24:55 (GVA Time) using Doxygen 1.10.0