Change root default palette

I am unable to change default palette. i tried editing both .rootrc and rootlogon.C but nothing changes. I am currently trying to set kRainBow palette that should be selected by gStyle->SetPalette(55); what am i doing wrong?
currently on root 6.18/04

The “kRainBow” enum should be available in ROOT 6.04 and newer versions but “55” should also work starting from recent ROOT 5.34 versions. Try:

gStyle->SetPalette(55);
TF2 *f = new TF2("f", "0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))", 1., 3., 1., 3.);
f->Draw("colz");

It is working.
but how to set up as default palette from start ( i mean withouth having to do gStyle->SetPalaette(55) every time i open a new root instance)?

Add it to your “rootlogon.C” file.

i did, but still not working.

Inspect:

grep Rint.Logon ${ROOTSYS}/etc/system.rootrc `root-config --etcdir`/system.rootrc ${HOME}/.rootrc ./.rootrc

Note: In general, the “rootlogon.C” file should be in your “current working directory”. Try to rename the “${HOME}/rootlogon.C” into the “${HOME}/.rootlogon.C” (if you want a “global” one).

Aw thanks! now i understood the problem!
now i got this error /Users/palazz/.rootlogon.C:1:1: error: unknown type name ‘gStyle’
gStyle->SetPalette(55);
^
/Users/palazz/.rootlogon.C:1:7: error: cannot use arrow operator on a type
gStyle->SetPalette(55);
^

It is supposed to be a valid ROOT macro so, begin it with a “{” and end it with a “}”.

Ok, added brackets. i don’t get that error anymore. Palette doesn’t change though.
There should be something i m doing wrong… my .rootlogon on home directory looks this way
{
gStyle->SetPalette(55);
}

You should add this in the file rootlogon.C in the directory where you start root.
Can you post here the rootlogon.C file you have ?

@couet Note that you CAN have a global “${HOME}/.rootlogon.C” file (well, at least on Linux).

rootlogon.C (56 Bytes)
this is my .rootlogon.C file (had to rename it to make it visibile)

here is what i get:
root -l
it works
root [0]
but palette has not changed…

I know.
i was just tried to make it simpler.

so the file .rootlogon.C in executed. 55 is a valid palette … it is RainBow …
What to you do to see the palette ?

simply do what @Wile_E_Coyote suggested:

root [0] TF2 *f = new TF2("f", "0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))", 1., 3., 1., 3.);
root [1] f->Draw("colz");

this is what i get:

and this is like kRainBow Should look like:

Here is my root history:
it works
root [0] TF2 f = new TF2(“f”, "0.1+(1-(x-2)(x-2))(1-(y-2)(y-2))", 1., 3., 1., 3.);
root [1] f->Draw(“colz”);
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1
root [2] gStyle->SetPalette(55);
root [3] f->Draw(“colz”);

This is weird because the first palette you get does not seem to be one of the standard ROOT palettes. You changed .rootlogon.C in your home directory but may be you have a file rootlogon.C in your current directory, doing some palette changes also ?

Aw you are right… i started root doing root -n and i got another palette… so i have a rootlogon somewhere changing it…
EDIT: Found the alternative rootlogon.C located into root/etc/

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.