Draw color plots using different color palettes.
As only one palette is active, one need to use TExec
to be able to display plots using different palettes on the same pad.
When a pad is painted, all its elements are painted in the sequence of Draw calls (See the difference between Draw and Paint in the TPad documentation); for TExec it executes its command - which in the following example sets palette for painting all objects painted afterwards. If in the next pad another TExec changes the palette, it doesn’t affect the previous pad which was already painted, but it will affect the current and those painted later.
The following macro illustrate this feature.
void Pal1()
{
Double_t Green[3] = { 0.00, 1.00, 0.00};
Double_t Length[3] = { 0.00, 0.50, 1.00 };
if(!initialized){
for (
int i=0; i<50; i++)
colors[i] = FI+i;
return;
}
}
void Pal2()
{
Double_t Green[3] = { 0.50, 0.00, 1.00};
Double_t Length[3] = { 0.00, 0.50, 1.00 };
if(!initialized){
for (
int i=0; i<50; i++)
colors[i] = FI+i;
return;
}
}
void multipalette() {
TF2 *f3 =
new TF2(
"f3",
"0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",1,3,1,3);
}
R__EXTERN TStyle * gStyle
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
static Int_t CreateGradientColorTable(UInt_t Number, Double_t *Stops, Double_t *Red, Double_t *Green, Double_t *Blue, UInt_t NColors, Float_t alpha=1.)
Static function creating a color table with several connected linear gradients.
TExec is a utility class that can be used to execute a C++ command when some event happens in a pad.
A 2-Dim function with parameters.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
- Author
- Olivier Couet
Definition in file multipalette.C.