ROOT
v6-20
Reference Guide
palettes.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_graphics
3
/// \notebook
4
/// This macro draws all the high definition palettes available in ROOT.
5
/// It generates a png file for each palette and one pdf file, with a table of
6
/// content, containing all the palettes.
7
///
8
/// In ROOT, [more than 60 high quality palettes are predefined with 255 colors each](https://root.cern/doc/master/classTColor.html#C06).
9
///
10
/// These palettes can be accessed "by name" with `gStyle->SetPalette(num)`. num
11
/// can be taken within the enum given in the previous link. As an example
12
/// `gStyle->SetPalette(kCividis)` will select the following palette.
13
///
14
/// \macro_image
15
/// \macro_code
16
///
17
/// \author Olivier Couet
18
19
TCanvas
*
c
;
20
21
void
draw_palette(
int
p,
TString
n
){
22
delete
c
;
23
c
=
new
TCanvas
(
"c"
,
"Contours"
,0,0,500,500);
24
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);
25
f2->
SetContour
(99);
26
gStyle
->
SetPalette
(p);
27
f2->
SetLineWidth
(1);
28
f2->
SetLineColor
(
kBlack
);
29
f2->
Draw
(
"surf1z"
);
30
31
// Title
32
TPaveText
*
pt
=
new
TPaveText
(10,11,10,11,
"blNDC"
);
33
pt
->
SetName
(
"title"
);
34
pt
->
Draw
();
35
TString
num =
n
;
36
num.
ReplaceAll
(
" "
,
""
);
37
TLatex
*
l
=
new
TLatex
(-0.8704441,0.9779387,
Form
(
"Palette #%d: %s #scale[0.7]{(#font[82]{k%s})}"
,p,
n
.Data(),num.
Data
()));
38
l
->SetTextFont(42);
39
l
->SetTextSize(0.035);
40
l
->Draw();
41
c
->Update();
42
c
->Print(
Form
(
"palette_%d.png"
,p));
43
if
(p==51) {
c
->Print(
"palettes.pdf("
,
Form
(
"Title:%s"
,
n
.Data()));
return
;}
44
if
(p==111) {
c
->Print(
"palettes.pdf)"
,
Form
(
"Title:%s"
,
n
.Data()));
return
;}
45
c
->Print(
"palettes.pdf"
,
Form
(
"Title:%s"
,
n
.Data()));
46
}
47
48
void
palettes() {
49
gROOT
->SetBatch(1);
50
c
=
new
TCanvas
(
"c"
,
"Contours"
,0,0,500,500);
51
draw_palette(
kDeepSea
,
"Deap Sea"
);
52
draw_palette(
kGreyScale
,
"Grey Scale"
);
53
draw_palette(
kDarkBodyRadiator
,
"Dark Body Radiator"
);
54
draw_palette(
kBlueYellow
,
"Blue Yellow"
);
55
draw_palette(
kRainBow
,
"Rain Bow"
);
56
draw_palette(
kInvertedDarkBodyRadiator
,
"Inverted Dark Body Radiator"
);
57
draw_palette(
kBird
,
"Bird"
);
58
draw_palette(
kCubehelix
,
"Cube helix"
);
59
draw_palette(
kGreenRedViolet
,
"Green Red Violet"
);
60
draw_palette(
kBlueRedYellow
,
"Blue Red Yellow"
);
61
draw_palette(
kOcean
,
"Ocean"
);
62
draw_palette(
kColorPrintableOnGrey
,
"Color Printable On Grey"
);
63
draw_palette(
kAlpine
,
"Alpine"
);
64
draw_palette(
kAquamarine
,
"Aquamarine"
);
65
draw_palette(
kArmy
,
"Army"
);
66
draw_palette(
kAtlantic
,
"Atlantic"
);
67
draw_palette(
kAurora
,
"Aurora"
);
68
draw_palette(
kAvocado
,
"Avocado"
);
69
draw_palette(
kBeach
,
"Beach"
);
70
draw_palette(
kBlackBody
,
"Black Body"
);
71
draw_palette(
kBlueGreenYellow
,
"Blue Green Yellow"
);
72
draw_palette(
kBrownCyan
,
"Brown Cyan"
);
73
draw_palette(
kCMYK
,
"CMYK"
);
74
draw_palette(
kCandy
,
"Candy"
);
75
draw_palette(
kCherry
,
"Cherry"
);
76
draw_palette(
kCoffee
,
"Coffee"
);
77
draw_palette(
kDarkRainBow
,
"Dark Rain Bow"
);
78
draw_palette(
kDarkTerrain
,
"Dark Terrain"
);
79
draw_palette(
kFall
,
"Fall"
);
80
draw_palette(
kFruitPunch
,
"Fruit Punch"
);
81
draw_palette(
kFuchsia
,
"Fuchsia"
);
82
draw_palette(
kGreyYellow
,
"Grey Yellow"
);
83
draw_palette(
kGreenBrownTerrain
,
"Green Brown Terrain"
);
84
draw_palette(
kGreenPink
,
"Green Pink"
);
85
draw_palette(
kIsland
,
"Island"
);
86
draw_palette(
kLake
,
"Lake"
);
87
draw_palette(
kLightTemperature
,
"Light Temperature"
);
88
draw_palette(
kLightTerrain
,
"Light Terrain"
);
89
draw_palette(
kMint
,
"Mint"
);
90
draw_palette(
kNeon
,
"Neon"
);
91
draw_palette(
kPastel
,
"Pastel"
);
92
draw_palette(
kPearl
,
"Pearl"
);
93
draw_palette(
kPigeon
,
"Pigeon"
);
94
draw_palette(
kPlum
,
"Plum"
);
95
draw_palette(
kRedBlue
,
"Red Blue"
);
96
draw_palette(
kRose
,
"Rose"
);
97
draw_palette(
kRust
,
"Rust"
);
98
draw_palette(
kSandyTerrain
,
"Sandy Terrain"
);
99
draw_palette(
kSienna
,
"Sienna"
);
100
draw_palette(
kSolar
,
"Solar"
);
101
draw_palette(
kSouthWest
,
"South West"
);
102
draw_palette(
kStarryNight
,
"Starry Night"
);
103
draw_palette(
kSunset
,
"Sunset"
);
104
draw_palette(
kTemperatureMap
,
"Temperature Map"
);
105
draw_palette(
kThermometer
,
"Thermometer"
);
106
draw_palette(
kValentine
,
"Valentine"
);
107
draw_palette(
kVisibleSpectrum
,
"Visible Spectrum"
);
108
draw_palette(
kWaterMelon
,
"Water Melon"
);
109
draw_palette(
kCool
,
"Cool"
);
110
draw_palette(
kCopper
,
"Copper"
);
111
draw_palette(
kGistEarth
,
"Gist Earth"
);
112
draw_palette(
kViridis
,
"Viridis"
);
113
draw_palette(
kCividis
,
"Cividis"
);
114
}
115
c
#define c(i)
Definition:
RSha256.hxx:101
kBlack
@ kBlack
Definition:
Rtypes.h:63
kFall
@ kFall
Definition:
TColor.h:116
kStarryNight
@ kStarryNight
Definition:
TColor.h:124
kAtlantic
@ kAtlantic
Definition:
TColor.h:112
kIsland
@ kIsland
Definition:
TColor.h:118
kBlackBody
@ kBlackBody
Definition:
TColor.h:113
kFruitPunch
@ kFruitPunch
Definition:
TColor.h:116
kArmy
@ kArmy
Definition:
TColor.h:111
kAurora
@ kAurora
Definition:
TColor.h:112
kBrownCyan
@ kBrownCyan
Definition:
TColor.h:114
kBeach
@ kBeach
Definition:
TColor.h:113
kAquamarine
@ kAquamarine
Definition:
TColor.h:111
kPastel
@ kPastel
Definition:
TColor.h:120
kCubehelix
@ kCubehelix
Definition:
TColor.h:109
kAvocado
@ kAvocado
Definition:
TColor.h:112
kGreenRedViolet
@ kGreenRedViolet
Definition:
TColor.h:109
kAlpine
@ kAlpine
Definition:
TColor.h:111
kVisibleSpectrum
@ kVisibleSpectrum
Definition:
TColor.h:125
kCMYK
@ kCMYK
Definition:
TColor.h:114
kInvertedDarkBodyRadiator
@ kInvertedDarkBodyRadiator
Definition:
TColor.h:108
kWaterMelon
@ kWaterMelon
Definition:
TColor.h:126
kOcean
@ kOcean
Definition:
TColor.h:110
kDarkBodyRadiator
@ kDarkBodyRadiator
Definition:
TColor.h:107
kDarkTerrain
@ kDarkTerrain
Definition:
TColor.h:116
kLightTemperature
@ kLightTemperature
Definition:
TColor.h:119
kRust
@ kRust
Definition:
TColor.h:122
kCopper
@ kCopper
Definition:
TColor.h:126
kTemperatureMap
@ kTemperatureMap
Definition:
TColor.h:124
kSolar
@ kSolar
Definition:
TColor.h:123
kRedBlue
@ kRedBlue
Definition:
TColor.h:121
kDeepSea
@ kDeepSea
Definition:
TColor.h:107
kRainBow
@ kRainBow
Definition:
TColor.h:108
kSouthWest
@ kSouthWest
Definition:
TColor.h:123
kPlum
@ kPlum
Definition:
TColor.h:121
kGreenBrownTerrain
@ kGreenBrownTerrain
Definition:
TColor.h:117
kGreyYellow
@ kGreyYellow
Definition:
TColor.h:117
kGreyScale
@ kGreyScale
Definition:
TColor.h:107
kRose
@ kRose
Definition:
TColor.h:122
kSunset
@ kSunset
Definition:
TColor.h:124
kCoffee
@ kCoffee
Definition:
TColor.h:115
kGreenPink
@ kGreenPink
Definition:
TColor.h:118
kColorPrintableOnGrey
@ kColorPrintableOnGrey
Definition:
TColor.h:110
kSienna
@ kSienna
Definition:
TColor.h:123
kBlueYellow
@ kBlueYellow
Definition:
TColor.h:108
kBlueRedYellow
@ kBlueRedYellow
Definition:
TColor.h:110
kValentine
@ kValentine
Definition:
TColor.h:125
kSandyTerrain
@ kSandyTerrain
Definition:
TColor.h:122
kDarkRainBow
@ kDarkRainBow
Definition:
TColor.h:115
kViridis
@ kViridis
Definition:
TColor.h:127
kCandy
@ kCandy
Definition:
TColor.h:114
kCherry
@ kCherry
Definition:
TColor.h:115
kNeon
@ kNeon
Definition:
TColor.h:120
kBird
@ kBird
Definition:
TColor.h:109
kFuchsia
@ kFuchsia
Definition:
TColor.h:117
kBlueGreenYellow
@ kBlueGreenYellow
Definition:
TColor.h:113
kPearl
@ kPearl
Definition:
TColor.h:120
kPigeon
@ kPigeon
Definition:
TColor.h:121
kCividis
@ kCividis
Definition:
TColor.h:127
kCool
@ kCool
Definition:
TColor.h:126
kLake
@ kLake
Definition:
TColor.h:118
kMint
@ kMint
Definition:
TColor.h:119
kGistEarth
@ kGistEarth
Definition:
TColor.h:127
kThermometer
@ kThermometer
Definition:
TColor.h:125
kLightTerrain
@ kLightTerrain
Definition:
TColor.h:119
gROOT
#define gROOT
Definition:
TROOT.h:415
Form
char * Form(const char *fmt,...)
gStyle
R__EXTERN TStyle * gStyle
Definition:
TStyle.h:407
TAttLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition:
TAttLine.h:43
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition:
TAttLine.h:40
TCanvas
The Canvas class.
Definition:
TCanvas.h:31
TF2
A 2-Dim function with parameters.
Definition:
TF2.h:29
TF2::SetContour
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
Definition:
TF2.cxx:897
TF2::Draw
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition:
TF2.cxx:241
TLatex
To draw Mathematical Formula.
Definition:
TLatex.h:18
TPaveText
A Pave (see TPave) with text, lines or/and boxes inside.
Definition:
TPaveText.h:21
TPaveText::Draw
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition:
TPaveText.cxx:233
TPave::SetName
virtual void SetName(const char *name="")
Definition:
TPave.h:75
TString
Basic string class.
Definition:
TString.h:131
TString::Data
const char * Data() const
Definition:
TString.h:364
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition:
TString.h:687
TStyle::SetPalette
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition:
TStyle.cxx:1643
pt
TPaveText * pt
Definition:
entrylist_figure1.C:7
n
const Int_t n
Definition:
legend1.C:16
l
auto * l
Definition:
textangle.C:4
tutorials
graphics
palettes.C
ROOT v6-20 - Reference Guide Generated on Fri Apr 1 2022 00:23:48 (GVA Time) using Doxygen 1.9.4