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.
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);
TLatex *
l =
new TLatex(-0.8704441,0.9779387,
Form(
"Palette #%d: %s #scale[0.7]{(#font[82]{k%s})}",p,
n.Data(),num.
Data()));
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() {
c =
new TCanvas(
"c",
"Contours",0,0,500,500);
draw_palette(
kBird,
"Bird");
draw_palette(
kOcean,
"Ocean");
draw_palette(
kArmy,
"Army");
draw_palette(
kBeach,
"Beach");
draw_palette(
kCMYK,
"CMYK");
draw_palette(
kCandy,
"Candy");
draw_palette(
kFall,
"Fall");
draw_palette(
kLake,
"Lake");
draw_palette(
kMint,
"Mint");
draw_palette(
kNeon,
"Neon");
draw_palette(
kPearl,
"Pearl");
draw_palette(
kPlum,
"Plum");
draw_palette(
kRose,
"Rose");
draw_palette(
kRust,
"Rust");
draw_palette(
kSolar,
"Solar");
draw_palette(
kCool,
"Cool");
}
@ kInvertedDarkBodyRadiator
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
A 2-Dim function with parameters.
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
To draw Mathematical Formula.
A Pave (see TPave) with text, lines or/and boxes inside.
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
virtual void SetName(const char *name="")
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
- Author
- Olivier Couet
Definition in file palettes.C.