Logo ROOT   6.10/09
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 /// \macro_image
9 /// \macro_code
10 ///
11 /// \author Olivier Couet
12 
13 TCanvas *c;
14 
15 void draw_palette(int p, TString n){
16  delete c;
17  c = new TCanvas("c","Contours",0,0,500,500);
18  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);
19  f2->SetContour(99);
20  gStyle->SetPalette(p);
21  f2->SetLineWidth(1);
22  f2->SetLineColor(kBlack);
23  f2->Draw("surf1z");
24 
25  // Title
26  TPaveText *pt = new TPaveText(10,11,10,11,"blNDC");
27  pt->SetName("title");
28  pt->Draw();
29  TString num = n;
30  num.ReplaceAll(" ","");
31  TLatex *l = new TLatex(-0.8704441,0.9779387,Form("Palette #%d: %s #scale[0.7]{(#font[82]{k%s})}",p,n.Data(),num.Data()));
32  l->SetTextFont(42);
33  l->SetTextSize(0.035);
34  l->Draw();
35  c->Update();
36  c->Print(Form("palette_%d.png",p));
37  if (p==51) {c->Print("palettes.pdf(", Form("Title:%s",n.Data())); return;}
38  if (p==111) {c->Print("palettes.pdf)", Form("Title:%s",n.Data())); return;}
39  c->Print("palettes.pdf", Form("Title:%s",n.Data()));
40 }
41 
42 void palettes() {
43  gROOT->SetBatch(1);
44  c = new TCanvas("c","Contours",0,0,500,500);
45  draw_palette(kDeepSea, "Deap Sea");
46  draw_palette(kGreyScale, "Grey Scale");
47  draw_palette(kDarkBodyRadiator, "Dark Body Radiator");
48  draw_palette(kBlueYellow, "Blue Yellow");
49  draw_palette(kRainBow, "Rain Bow");
50  draw_palette(kInvertedDarkBodyRadiator, "Inverted Dark Body Radiator");
51  draw_palette(kBird, "Bird");
52  draw_palette(kCubehelix, "Cube helix");
53  draw_palette(kGreenRedViolet, "Green Red Violet");
54  draw_palette(kBlueRedYellow, "Blue Red Yellow");
55  draw_palette(kOcean, "Ocean");
56  draw_palette(kColorPrintableOnGrey, "Color Printable On Grey");
57  draw_palette(kAlpine, "Alpine");
58  draw_palette(kAquamarine, "Aquamarine");
59  draw_palette(kArmy, "Army");
60  draw_palette(kAtlantic, "Atlantic");
61  draw_palette(kAurora, "Aurora");
62  draw_palette(kAvocado, "Avocado");
63  draw_palette(kBeach, "Beach");
64  draw_palette(kBlackBody, "Black Body");
65  draw_palette(kBlueGreenYellow, "Blue Green Yellow");
66  draw_palette(kBrownCyan, "Brown Cyan");
67  draw_palette(kCMYK, "CMYK");
68  draw_palette(kCandy, "Candy");
69  draw_palette(kCherry, "Cherry");
70  draw_palette(kCoffee, "Coffee");
71  draw_palette(kDarkRainBow, "Dark Rain Bow");
72  draw_palette(kDarkTerrain, "Dark Terrain");
73  draw_palette(kFall, "Fall");
74  draw_palette(kFruitPunch, "Fruit Punch");
75  draw_palette(kFuchsia, "Fuchsia");
76  draw_palette(kGreyYellow, "Grey Yellow");
77  draw_palette(kGreenBrownTerrain, "Green Brown Terrain");
78  draw_palette(kGreenPink, "Green Pink");
79  draw_palette(kIsland, "Island");
80  draw_palette(kLake, "Lake");
81  draw_palette(kLightTemperature, "Light Temperature");
82  draw_palette(kLightTerrain, "Light Terrain");
83  draw_palette(kMint, "Mint");
84  draw_palette(kNeon, "Neon");
85  draw_palette(kPastel, "Pastel");
86  draw_palette(kPearl, "Pearl");
87  draw_palette(kPigeon, "Pigeon");
88  draw_palette(kPlum, "Plum");
89  draw_palette(kRedBlue, "Red Blue");
90  draw_palette(kRose, "Rose");
91  draw_palette(kRust, "Rust");
92  draw_palette(kSandyTerrain, "Sandy Terrain");
93  draw_palette(kSienna, "Sienna");
94  draw_palette(kSolar, "Solar");
95  draw_palette(kSouthWest, "South West");
96  draw_palette(kStarryNight, "Starry Night");
97  draw_palette(kSunset, "Sunset");
98  draw_palette(kTemperatureMap, "Temperature Map");
99  draw_palette(kThermometer, "Thermometer");
100  draw_palette(kValentine, "Valentine");
101  draw_palette(kVisibleSpectrum, "Visible Spectrum");
102  draw_palette(kWaterMelon, "Water Melon");
103  draw_palette(kCool, "Cool");
104  draw_palette(kCopper, "Copper");
105  draw_palette(kGistEarth, "Gist Earth");
106  draw_palette(kViridis, "Viridis");
107 }
108 
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetName(const char *name="")
Definition: TPave.h:72
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF2.cxx:217
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:234
Definition: TColor.h:117
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:640
R__EXTERN TStyle * gStyle
Definition: TStyle.h:402
Definition: Rtypes.h:55
Definition: TColor.h:115
#define gROOT
Definition: TROOT.h:375
Definition: TColor.h:113
Basic string class.
Definition: TString.h:129
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:202
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:45
Definition: TColor.h:111
Definition: TColor.h:117
To draw Mathematical Formula.
Definition: TLatex.h:18
Definition: TColor.h:116
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
TPaveText * pt
char * Form(const char *fmt,...)
Definition: TColor.h:114
TLine * l
Definition: textangle.C:4
Definition: TColor.h:121
Definition: TColor.h:105
A 2-Dim function with parameters.
Definition: TF2.h:29
virtual void Print(const char *filename="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:4581
Definition: TColor.h:109
The Canvas class.
Definition: TCanvas.h:31
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
Definition: TColor.h:109
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
Definition: TF2.cxx:873
Definition: TColor.h:115
Definition: TColor.h:108
Definition: TColor.h:118
Definition: TColor.h:106
double f2(const double *x)
Definition: TColor.h:104
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:46
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2208
const Int_t n
Definition: legend1.C:16
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1460
const char * Data() const
Definition: TString.h:347