Hello,
I am trying to make two plots on a single TCanvas, one with a kBird color palette and one with a custom defined color palette, using the following lines of code:
// Draw histogram
c2->Divide(2,2);
c2->cd(1); gPad->SetLeftMargin(0.15); histData->GetYaxis()->SetTitleOffset(1.6); histData->Draw("col");
c2->cd(1); gPad->SetLeftMargin(0.15); histBack->GetYaxis()->SetTitleOffset(1.6); histBack->Draw("same cont2");
//c2->cd(1); gPad->SetLeftMargin(0.15); histB->GetYaxis()->SetTitleOffset(1.6); histB->Draw("same cont2");
c2->cd(1); gPad->SetLeftMargin(0.15); histSig->GetYaxis()->SetTitleOffset(1.6); histSig->Draw("same cont2");
c2->cd(2);
const Int_t NCont2 = 255;
Double_t stops2[NRGBs2] = { 0.00, 0.45, 0.55, 1.00};
Double_t reds2[NRGBs2] = { 0.00, 1.00, 1.00, 1.00};
Double_t greens2[NRGBs2] = { 0.00, 1.00, 1.00, 0.00};
Double_t blues2[NRGBs2] = { 1.00, 1.00, 1.00, 0.00};
TColor::CreateGradientColorTable(NRGBs2, stops2, reds2, greens2, blues2, NCont2);
gStyle->SetNumberContours(NCont2)
// Adaptive Binning
modelPoly->SetMinimum(-4.);
modelPoly->SetMaximum( 4.);
gPad->SetLeftMargin(0.15); modelPoly->GetYaxis()->SetTitleOffset(1.6); modelPoly->Draw("colz");
c2->cd(3); gPad->SetLeftMargin(0.15); m1Plot->GetYaxis()->SetTitleOffset(1.6); m1Plot->Draw();
c2->cd(4); gPad->SetLeftMargin(0.15); m2Plot->GetYaxis()->SetTitleOffset(1.6); m2Plot->Draw();
However, this just results in both the histogram plotted in cd(1) and the one plotted in cd(2) having the same color scheme - namely, the one defined after the line “c2->cd(2)” . I tried explicitly calling gStyle->SetPalette(“kBird”) after the line “c2->cd(1),” but this did not change the result. Then, I tried following the instructions in this multi-palette tutorial, but this did not work either.
It seems as though ROOT is using whichever color palette that is last set in order to plot both of my histograms. I tried switching the order with which I set the color palettes, and this only resulted in the entire canvas being plotted with kBird. This is a particularly strange behavior, since my advisor tried running similar code with explicit calls to SetPalette, and it plotted both color palettes correctly.
Has anyone else encountered this issue and know how to solve it?
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.20/04
Platform: Windows Subsystem for Linux
Compiler: GCC