Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
palettes.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphics
3/// \notebook
4/// \preview 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
9/// each](https://root.cern/doc/master/classTColor.html#C06).
10///
11/// These palettes can be accessed "by name" with `gStyle->SetPalette(num)`. num
12/// can be taken within the enum given in the previous link. As an example
13/// `gStyle->SetPalette(kCividis)` will select the following palette.
14///
15/// \macro_image
16/// \macro_code
17///
18/// \author Olivier Couet
19
20TCanvas *c = nullptr;
21
22void draw_palette(int p, TString n)
23{
24 delete c;
25 c = new TCanvas("c", "Contours", 0, 0, 500, 500);
26 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);
27 f2->SetContour(99);
29 f2->SetLineWidth(1);
31 f2->Draw("surf1z");
32
33 // Title
34 TPaveText *pt = new TPaveText(10, 11, 10, 11, "blNDC");
35 pt->SetName("title");
36 pt->Draw();
37 TString num = n;
38 num.ReplaceAll(" ", "");
39 TLatex *l = new TLatex(-0.8704441, 0.9779387,
40 TString::Format("Palette #%d: %s #scale[0.7]{(#font[82]{k%s})}", p, n.Data(), num.Data()));
41 l->SetTextFont(42);
42 l->SetTextSize(0.035);
43 l->Draw();
44 c->Update();
45 c->Print(TString::Format("palette_%d.png", p));
46
47 TString opt = TString("Title:") + n;
48 if (p == kDeepSea)
49 c->Print("palettes.pdf(", opt.Data());
50 else if (p == kCividis)
51 c->Print("palettes.pdf)", opt.Data());
52 else
53 c->Print("palettes.pdf", opt.Data());
54}
55
56void palettes()
57{
58 gROOT->SetBatch(1);
59 draw_palette(kDeepSea, "Deap Sea");
60 draw_palette(kGreyScale, "Grey Scale");
61 draw_palette(kDarkBodyRadiator, "Dark Body Radiator");
62 draw_palette(kBlueYellow, "Blue Yellow");
63 draw_palette(kRainBow, "Rain Bow");
64 draw_palette(kInvertedDarkBodyRadiator, "Inverted Dark Body Radiator");
65 draw_palette(kBird, "Bird");
66 draw_palette(kCubehelix, "Cube helix");
67 draw_palette(kGreenRedViolet, "Green Red Violet");
68 draw_palette(kBlueRedYellow, "Blue Red Yellow");
69 draw_palette(kOcean, "Ocean");
70 draw_palette(kColorPrintableOnGrey, "Color Printable On Grey");
71 draw_palette(kAlpine, "Alpine");
72 draw_palette(kAquamarine, "Aquamarine");
73 draw_palette(kArmy, "Army");
74 draw_palette(kAtlantic, "Atlantic");
75 draw_palette(kAurora, "Aurora");
76 draw_palette(kAvocado, "Avocado");
77 draw_palette(kBeach, "Beach");
78 draw_palette(kBlackBody, "Black Body");
79 draw_palette(kBlueGreenYellow, "Blue Green Yellow");
80 draw_palette(kBrownCyan, "Brown Cyan");
81 draw_palette(kCMYK, "CMYK");
82 draw_palette(kCandy, "Candy");
83 draw_palette(kCherry, "Cherry");
84 draw_palette(kCoffee, "Coffee");
85 draw_palette(kDarkRainBow, "Dark Rain Bow");
86 draw_palette(kDarkTerrain, "Dark Terrain");
87 draw_palette(kFall, "Fall");
88 draw_palette(kFruitPunch, "Fruit Punch");
89 draw_palette(kFuchsia, "Fuchsia");
90 draw_palette(kGreyYellow, "Grey Yellow");
91 draw_palette(kGreenBrownTerrain, "Green Brown Terrain");
92 draw_palette(kGreenPink, "Green Pink");
93 draw_palette(kIsland, "Island");
94 draw_palette(kLake, "Lake");
95 draw_palette(kLightTemperature, "Light Temperature");
96 draw_palette(kLightTerrain, "Light Terrain");
97 draw_palette(kMint, "Mint");
98 draw_palette(kNeon, "Neon");
99 draw_palette(kPastel, "Pastel");
100 draw_palette(kPearl, "Pearl");
101 draw_palette(kPigeon, "Pigeon");
102 draw_palette(kPlum, "Plum");
103 draw_palette(kRedBlue, "Red Blue");
104 draw_palette(kRose, "Rose");
105 draw_palette(kRust, "Rust");
106 draw_palette(kSandyTerrain, "Sandy Terrain");
107 draw_palette(kSienna, "Sienna");
108 draw_palette(kSolar, "Solar");
109 draw_palette(kSouthWest, "South West");
110 draw_palette(kStarryNight, "Starry Night");
111 draw_palette(kSunset, "Sunset");
112 draw_palette(kTemperatureMap, "Temperature Map");
113 draw_palette(kThermometer, "Thermometer");
114 draw_palette(kValentine, "Valentine");
115 draw_palette(kVisibleSpectrum, "Visible Spectrum");
116 draw_palette(kWaterMelon, "Water Melon");
117 draw_palette(kCool, "Cool");
118 draw_palette(kCopper, "Copper");
119 draw_palette(kGistEarth, "Gist Earth");
120 draw_palette(kViridis, "Viridis");
121 draw_palette(kCividis, "Cividis");
122}
#define c(i)
Definition RSha256.hxx:101
@ kBlack
Definition Rtypes.h:65
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kFall
Definition TColor.h:128
@ kStarryNight
Definition TColor.h:136
@ kAtlantic
Definition TColor.h:124
@ kIsland
Definition TColor.h:130
@ kBlackBody
Definition TColor.h:125
@ kFruitPunch
Definition TColor.h:128
@ kArmy
Definition TColor.h:123
@ kAurora
Definition TColor.h:124
@ kBrownCyan
Definition TColor.h:126
@ kBeach
Definition TColor.h:125
@ kAquamarine
Definition TColor.h:123
@ kPastel
Definition TColor.h:132
@ kCubehelix
Definition TColor.h:121
@ kAvocado
Definition TColor.h:124
@ kGreenRedViolet
Definition TColor.h:121
@ kAlpine
Definition TColor.h:123
@ kVisibleSpectrum
Definition TColor.h:137
@ kCMYK
Definition TColor.h:126
@ kInvertedDarkBodyRadiator
Definition TColor.h:120
@ kWaterMelon
Definition TColor.h:138
@ kOcean
Definition TColor.h:122
@ kDarkBodyRadiator
Definition TColor.h:119
@ kDarkTerrain
Definition TColor.h:128
@ kLightTemperature
Definition TColor.h:131
@ kRust
Definition TColor.h:134
@ kCopper
Definition TColor.h:138
@ kTemperatureMap
Definition TColor.h:136
@ kSolar
Definition TColor.h:135
@ kRedBlue
Definition TColor.h:133
@ kDeepSea
Definition TColor.h:119
@ kRainBow
Definition TColor.h:120
@ kSouthWest
Definition TColor.h:135
@ kPlum
Definition TColor.h:133
@ kGreenBrownTerrain
Definition TColor.h:129
@ kGreyYellow
Definition TColor.h:129
@ kGreyScale
Definition TColor.h:119
@ kRose
Definition TColor.h:134
@ kSunset
Definition TColor.h:136
@ kCoffee
Definition TColor.h:127
@ kGreenPink
Definition TColor.h:130
@ kColorPrintableOnGrey
Definition TColor.h:122
@ kSienna
Definition TColor.h:135
@ kBlueYellow
Definition TColor.h:120
@ kBlueRedYellow
Definition TColor.h:122
@ kValentine
Definition TColor.h:137
@ kSandyTerrain
Definition TColor.h:134
@ kDarkRainBow
Definition TColor.h:127
@ kViridis
Definition TColor.h:139
@ kCandy
Definition TColor.h:126
@ kCherry
Definition TColor.h:127
@ kNeon
Definition TColor.h:132
@ kBird
Definition TColor.h:121
@ kFuchsia
Definition TColor.h:129
@ kBlueGreenYellow
Definition TColor.h:125
@ kPearl
Definition TColor.h:132
@ kPigeon
Definition TColor.h:133
@ kCividis
Definition TColor.h:139
@ kCool
Definition TColor.h:138
@ kLake
Definition TColor.h:130
@ kMint
Definition TColor.h:131
@ kGistEarth
Definition TColor.h:139
@ kThermometer
Definition TColor.h:137
@ kLightTerrain
Definition TColor.h:131
winID h TVirtualViewer3D TVirtualGLPainter p
#define gROOT
Definition TROOT.h:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:45
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:42
The Canvas class.
Definition TCanvas.h:23
A 2-Dim function with parameters.
Definition TF2.h:29
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr)
Set the number and values of contour levels.
Definition TF2.cxx:939
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Definition TF2.cxx:269
To draw Mathematical Formula.
Definition TLatex.h:18
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:293
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
void Draw(Option_t *option="") override
Draw this pavetext with its current attributes.
virtual void SetName(const char *name="")
Definition TPave.h:81
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1890
TPaveText * pt
const Int_t n
Definition legend1.C:16
TLine l
Definition textangle.C:4