How to Have Two Different Color Palettes on the Same Canvas ?
ROOT only has one color palette active at a time. It can be changed using gStyle->SetPallette(). To have several palettes at the same time on the same picture one need to use TExec objects as illustrated in the following example:
{ gStyle->SetOptStat(0); TCanvas *c = new TCanvas("c","c",600,600); c->Divide(1,2); TH2F *h1 = new TH2F("h1","h1",40,-4,4,40,-4,4); TH2F *h2 = new TH2F("h2","h2",40,-4,4,40,-4,4); Double_t a,b; for (Int_t i=0;i<5000;i++) { gRandom->Rannor(a,b); h1->Fill(a-1.5,b-1.5); h2->Fill(a+1.5,b+1.5); } TExec *ex1 = new TExec("ex1","gStyle->SetPalette(0);"); TExec *ex2 = new TExec("ex2","gStyle->SetPalette(1);"); c->cd(1); h1->Draw("col"); ex1->Draw(); h1->Draw("colz same"); c->cd(2); h2->Draw("col"); ex2->Draw(); h2->Draw("colz same"); }
This macro produces the following output:
See also the article about the rainbow color map.