Logo ROOT  
Reference Guide
palettes.C File Reference

Detailed Description

View in nbviewer Open in SWAN This macro draws all the high definition palettes available in ROOT. It generates a png file for each palette and one pdf file, with a table of content, containing all the palettes.

In ROOT, more than 60 high quality palettes are predefined with 255 colors each.

These palettes can be accessed "by name" with gStyle->SetPalette(num). num can be taken within the enum given in the previous link. As an example gStyle->SetPalette(kCividis) will select the following palette.

void draw_palette(int p, TString n){
delete c;
c = new TCanvas("c","Contours",0,0,500,500);
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);
f2->SetContour(99);
f2->SetLineWidth(1);
f2->SetLineColor(kBlack);
f2->Draw("surf1z");
// Title
TPaveText *pt = new TPaveText(10,11,10,11,"blNDC");
pt->SetName("title");
pt->Draw();
TString num = n;
num.ReplaceAll(" ","");
TLatex *l = new TLatex(-0.8704441,0.9779387,Form("Palette #%d: %s #scale[0.7]{(#font[82]{k%s})}",p,n.Data(),num.Data()));
l->SetTextFont(42);
l->SetTextSize(0.035);
l->Draw();
c->Update();
c->Print(Form("palette_%d.png",p));
if (p==51) {c->Print("palettes.pdf(", Form("Title:%s",n.Data())); return;}
if (p==111) {c->Print("palettes.pdf)", Form("Title:%s",n.Data())); return;}
c->Print("palettes.pdf", Form("Title:%s",n.Data()));
}
void palettes() {
gROOT->SetBatch(1);
c = new TCanvas("c","Contours",0,0,500,500);
draw_palette(kDeepSea, "Deap Sea");
draw_palette(kGreyScale, "Grey Scale");
draw_palette(kDarkBodyRadiator, "Dark Body Radiator");
draw_palette(kBlueYellow, "Blue Yellow");
draw_palette(kRainBow, "Rain Bow");
draw_palette(kInvertedDarkBodyRadiator, "Inverted Dark Body Radiator");
draw_palette(kBird, "Bird");
draw_palette(kCubehelix, "Cube helix");
draw_palette(kGreenRedViolet, "Green Red Violet");
draw_palette(kBlueRedYellow, "Blue Red Yellow");
draw_palette(kOcean, "Ocean");
draw_palette(kColorPrintableOnGrey, "Color Printable On Grey");
draw_palette(kAlpine, "Alpine");
draw_palette(kAquamarine, "Aquamarine");
draw_palette(kArmy, "Army");
draw_palette(kAtlantic, "Atlantic");
draw_palette(kAurora, "Aurora");
draw_palette(kAvocado, "Avocado");
draw_palette(kBeach, "Beach");
draw_palette(kBlackBody, "Black Body");
draw_palette(kBlueGreenYellow, "Blue Green Yellow");
draw_palette(kBrownCyan, "Brown Cyan");
draw_palette(kCMYK, "CMYK");
draw_palette(kCandy, "Candy");
draw_palette(kCherry, "Cherry");
draw_palette(kCoffee, "Coffee");
draw_palette(kDarkRainBow, "Dark Rain Bow");
draw_palette(kDarkTerrain, "Dark Terrain");
draw_palette(kFall, "Fall");
draw_palette(kFruitPunch, "Fruit Punch");
draw_palette(kFuchsia, "Fuchsia");
draw_palette(kGreyYellow, "Grey Yellow");
draw_palette(kGreenBrownTerrain, "Green Brown Terrain");
draw_palette(kGreenPink, "Green Pink");
draw_palette(kIsland, "Island");
draw_palette(kLake, "Lake");
draw_palette(kLightTemperature, "Light Temperature");
draw_palette(kLightTerrain, "Light Terrain");
draw_palette(kMint, "Mint");
draw_palette(kNeon, "Neon");
draw_palette(kPastel, "Pastel");
draw_palette(kPearl, "Pearl");
draw_palette(kPigeon, "Pigeon");
draw_palette(kPlum, "Plum");
draw_palette(kRedBlue, "Red Blue");
draw_palette(kRose, "Rose");
draw_palette(kRust, "Rust");
draw_palette(kSandyTerrain, "Sandy Terrain");
draw_palette(kSienna, "Sienna");
draw_palette(kSolar, "Solar");
draw_palette(kSouthWest, "South West");
draw_palette(kStarryNight, "Starry Night");
draw_palette(kSunset, "Sunset");
draw_palette(kTemperatureMap, "Temperature Map");
draw_palette(kThermometer, "Thermometer");
draw_palette(kValentine, "Valentine");
draw_palette(kVisibleSpectrum, "Visible Spectrum");
draw_palette(kWaterMelon, "Water Melon");
draw_palette(kCool, "Cool");
draw_palette(kCopper, "Copper");
draw_palette(kGistEarth, "Gist Earth");
draw_palette(kViridis, "Viridis");
draw_palette(kCividis, "Cividis");
}
Author
Olivier Couet

Definition in file palettes.C.

c
#define c(i)
Definition: RSha256.hxx:119
l
auto * l
Definition: textangle.C:4
kLightTerrain
@ kLightTerrain
Definition: TColor.h:119
n
const Int_t n
Definition: legend1.C:16
kCopper
@ kCopper
Definition: TColor.h:126
kVisibleSpectrum
@ kVisibleSpectrum
Definition: TColor.h:125
kGreenBrownTerrain
@ kGreenBrownTerrain
Definition: TColor.h:117
kAvocado
@ kAvocado
Definition: TColor.h:112
kDarkRainBow
@ kDarkRainBow
Definition: TColor.h:115
kDeepSea
@ kDeepSea
Definition: TColor.h:107
kCherry
@ kCherry
Definition: TColor.h:115
kPigeon
@ kPigeon
Definition: TColor.h:121
kMint
@ kMint
Definition: TColor.h:119
kSunset
@ kSunset
Definition: TColor.h:124
kArmy
@ kArmy
Definition: TColor.h:111
TString::Data
const char * Data() const
Definition: TString.h:369
kPlum
@ kPlum
Definition: TColor.h:121
Form
char * Form(const char *fmt,...)
kAurora
@ kAurora
Definition: TColor.h:112
kGreenRedViolet
@ kGreenRedViolet
Definition: TColor.h:109
kCMYK
@ kCMYK
Definition: TColor.h:114
kBird
@ kBird
Definition: TColor.h:109
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
kRose
@ kRose
Definition: TColor.h:122
TLatex
Definition: TLatex.h:18
kBlueYellow
@ kBlueYellow
Definition: TColor.h:108
TString
Definition: TString.h:136
kPastel
@ kPastel
Definition: TColor.h:120
kCandy
@ kCandy
Definition: TColor.h:114
kAquamarine
@ kAquamarine
Definition: TColor.h:111
kTemperatureMap
@ kTemperatureMap
Definition: TColor.h:124
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TPaveText::Draw
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:234
kSouthWest
@ kSouthWest
Definition: TColor.h:123
kBeach
@ kBeach
Definition: TColor.h:113
kBlack
@ kBlack
Definition: Rtypes.h:65
kFruitPunch
@ kFruitPunch
Definition: TColor.h:116
kBrownCyan
@ kBrownCyan
Definition: TColor.h:114
kAtlantic
@ kAtlantic
Definition: TColor.h:112
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
kSandyTerrain
@ kSandyTerrain
Definition: TColor.h:122
kDarkTerrain
@ kDarkTerrain
Definition: TColor.h:116
kRainBow
@ kRainBow
Definition: TColor.h:108
kDarkBodyRadiator
@ kDarkBodyRadiator
Definition: TColor.h:107
kBlackBody
@ kBlackBody
Definition: TColor.h:113
kLightTemperature
@ kLightTemperature
Definition: TColor.h:119
kRedBlue
@ kRedBlue
Definition: TColor.h:121
kFuchsia
@ kFuchsia
Definition: TColor.h:117
kViridis
@ kViridis
Definition: TColor.h:127
TF2::Draw
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF2.cxx:241
kGreenPink
@ kGreenPink
Definition: TColor.h:118
kStarryNight
@ kStarryNight
Definition: TColor.h:124
kBlueGreenYellow
@ kBlueGreenYellow
Definition: TColor.h:113
kSolar
@ kSolar
Definition: TColor.h:123
kGreyScale
@ kGreyScale
Definition: TColor.h:107
TF2
Definition: TF2.h:29
kPearl
@ kPearl
Definition: TColor.h:120
kThermometer
@ kThermometer
Definition: TColor.h:125
kLake
@ kLake
Definition: TColor.h:118
kOcean
@ kOcean
Definition: TColor.h:110
TStyle::SetPalette
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1785
kGistEarth
@ kGistEarth
Definition: TColor.h:127
TCanvas
Definition: TCanvas.h:23
kWaterMelon
@ kWaterMelon
Definition: TColor.h:126
kRust
@ kRust
Definition: TColor.h:122
kColorPrintableOnGrey
@ kColorPrintableOnGrey
Definition: TColor.h:110
kNeon
@ kNeon
Definition: TColor.h:120
kCoffee
@ kCoffee
Definition: TColor.h:115
TPaveText
Definition: TPaveText.h:21
kSienna
@ kSienna
Definition: TColor.h:123
kFall
@ kFall
Definition: TColor.h:116
kCubehelix
@ kCubehelix
Definition: TColor.h:109
pt
TPaveText * pt
Definition: entrylist_figure1.C:7
TPave::SetName
virtual void SetName(const char *name="")
Definition: TPave.h:81
kCividis
@ kCividis
Definition: TColor.h:127
kCool
@ kCool
Definition: TColor.h:126
kIsland
@ kIsland
Definition: TColor.h:118
kBlueRedYellow
@ kBlueRedYellow
Definition: TColor.h:110
kAlpine
@ kAlpine
Definition: TColor.h:111
gROOT
#define gROOT
Definition: TROOT.h:406
kInvertedDarkBodyRadiator
@ kInvertedDarkBodyRadiator
Definition: TColor.h:108
kGreyYellow
@ kGreyYellow
Definition: TColor.h:117
kValentine
@ kValentine
Definition: TColor.h:125