Defining multiple styles in rootlogon.C

Hi,

I am attempting to define multiple styles with different color palettes in my rootlogon.C file. However, the second palette set overrides the first one, even though it is set for a different object.

Is this expected? If not, how should I prevent this from happening?

My rootlogon.C file is included below.

// Set up root default options
{
    TStyle *myCividis  = new TStyle("myCividis","Use Cividis color map");
    TStyle *myTableau  = new TStyle("myTableau","Use tableau color blind color cycle");

    // Define Cividis color map for myself as the required function exists
    Double_t civ_red[9]   = {  0./255.,   5./255.,  65./255.,  97./255., 124./255., 156./255., 189./255., 224./255., 255./255.};
    Double_t civ_green[9] = { 32./255.,  54./255.,  77./255., 100./255., 123./255., 148./255., 175./255., 203./255., 234./255.};
    Double_t civ_blue[9]  = { 77./255., 110./255., 107./255., 111./255., 120./255., 119./255., 111./255.,  94./255.,  70./255.};
    Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
    Float_t alpha = 1;
    Int_t FI = TColor::CreateGradientColorTable(9, stops, civ_red, civ_green, civ_blue, 255, alpha);

    Int_t MyCividis[255];
    for (int i = 0; i < 255; i++){
        MyCividis[i] = FI + i;
    }

    // Define the tableau colors (only use two)
    Int_t ct0 = 1701;
    Int_t ct1 = 1702;

    TColor *tab0 = new TColor(ct0, 0/255., 107/255., 164/255., "tab0");
    TColor *tab1 = new TColor(ct1, 255/255., 128/255., 74/255., "tab1");

    Int_t tableau_cb_10[2];
    tableau_cb_10[0] = tab0->GetNumber();
    tableau_cb_10[1] = tab1->GetNumber();

    myCividis->SetPalette(255, MyCividis);

    cout << "Before defining tableau" << endl;

    for (int i = 0; i < 255; i++){
        cout << MyCividis[i] << endl;
        cout << myCividis->GetColorPalette(i) << endl;
    }


    myTableau->SetPalette(2, tableau_cb_10);

    cout << "After defining tableau" << endl;

    for (int i = 0; i < 255; i++){
        cout << MyCividis[i] << endl;
        cout << myCividis->GetColorPalette(i) << endl;
    }
}


ROOT Version : 5.34/34


Yes only one palette is active at a given moment in ROOT. To have several palettes on the same plot you can proceed as shown here

Thank you for your reply.

To clarify: It is not possible to have multiple TStyle objects defined with different palettes, even if they are not used (without using TExec)?

The palette is a object apart from the style (there is no way to "put a palette in a TStyle"). There is one current palette active at a time. To have several palettes on the same plot one need to use the TExec trick.