TPaletteAxis

Hi,

I’'ve drawn two histograms, one on pad 1 and the other on pad 2. I’m not sure how I can show the palette on pad 3. Both histograms share the same palette.

Any help would be wonderful.

Thanks,
Nidhi

for more deatail see: root.cern.ch/root/htmldoc//TPaletteAxis.html

maybe this help:

{
  TH2F *h2 = new TH2F("h2","",50,-5,5,50,-5,5);
  h2->FillRandom("gaus",10000);
  
  gStyle->SetPalette(100);
  TCanvas *c1 = new TCanvas("c1","c1");
  TPad *c1_1  = new TPad("c1_1","c1_1",0.01,0.01,0.40,0.99); c1_1->Draw();
  TPad *c1_2  = new TPad("c1_2","c1_2",0.42,0.01,0.80,0.99); c1_2->Draw();
  TPad *c1_3  = new TPad("c1_3","c1_3",0.82,0.01,0.99,0.99); c1_3->Draw();
  
  c1_1->cd();
  h2->Draw("COLZ");
  c1_2->cd();
  h2->Clone("h2_clone");
  h2_clone->GetXaxis()->SetRange(16,35);
  h2_clone->Draw("COL");
  gPad->Update();
  // We have 2 histograms with the same palette
  
  c1_3->cd();
  TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
  palette->SetX1NDC(0.25);
  palette->SetX2NDC(0.75);
  palette->SetLabelOffset(0.03);
  palette->SetLabelSize(0.1);
  palette->Draw();
  gPad->Update();
  
  //  return;
  
  // without palette on first pad (histogram)
  c1_3->cd();
  palette->DrawClone();
  c1_1->cd();
  h2->Draw("COL"); // "redraw" without palette
  gPad->Update();
}

Jan

Thanks Jan, I like the trick of redrawing the histogram on pad 1.

Nidhi