Hi,
I’m plotting a scatter plot using a custom palette, defined as the same as written on page 135 of ROOT5.21 manual.
//Example of creating new colors and defining a new palette
void palette(int nCol) {
if (nCol <=0 || nCol >20)
nCol= 20;
const int colNum= nCol;
int startCol=210;
double colRatio=1.0;
int palette[ colNum];
for(int i=0; i<colNum; i++) {
// get the color and if it does not exists create it
if( i < (colNum+1)/2) {
if(! gROOT->GetColor(startCol+i))
TColor *color= new TColor(startCol+i,(i/( colNum/2*colRatio)), (i/( colNum/2*colRatio)), 1,"");
else {
TColor *color= gROOT->GetColor(startCol+i);
color->SetRGB( (i/( colNum/2*colRatio)), (i/( colNum/2*colRatio)), 1 );
}
}
else if (i == (colNum+1)/2) {
if(! gROOT->GetColor(startCol+i))
TColor *color= new TColor(startCol+i,1,1,1,"");
else {
TColor *color= gROOT->GetColor(startCol+i);
color->SetRGB( 1,1,1 );
}
}
else {
if(! gROOT->GetColor(startCol+i))
TColor *color= new TColor(startCol+i,1,colRatio-(i/( colNum/2*colRatio)),colRatio-(i/( colNum/2*colRatio)),"");
else {
TColor *color= gROOT->GetColor(startCol+i);
color->SetRGB( 1, colRatio-(i/( colNum/2*colRatio)),colRatio-(i/( colNum/2*colRatio)) );
}
}
palette[i] = startCol+i;
}
gStyle->SetPalette(colNum,palette);
}
This function is intended to define a palette of colors from plain blue shading to white, then to deep red.
The problem is that, while the TCanvas is perfect,
the printed eps file show just the blue colors spectrum and no difference in red colors.
Any hints to solve this little problem?
ps: if I print using a standard palette, using
gStyle->SetPalette(1);
everything works fine, but I cannot obviously obtain the effect I want.