Colz palette values truncated

Hi All,

When I draw a TH2 with “colz” options, depending on the values in the histogram and the width/height of the instantiated TCanvas there is potential for the colz palette’s values and/or title to be cut off at the edge of the canvas.

I suppose the solution is something like first grabbing the pad that the histogram is drawn on and moving that, and then grabbing the colz palette and moving that.

I’m attaching a simple script that generates a TH2D and then draws it on two different canvases, one of which the colz comes out OK, and one of which it comes out with truncated values.

Can anyone suggest a method to streamline the remedy for this that doesn’t require too much detailed tweaking of individual plots? Thanks!

Kevin
badcolz.C (548 Bytes)




void badcolz()
{
   TF1 poisson("poisson_func", "TMath::Poisson(x,[0]);;",0,10);
   poisson.SetParameter(0,4);

   TH2D* hist = new TH2D("hist","Bad Colz; X; Y",10,0,10,10,0,10);
   for (int i =0; i < 10000; i++) hist->Fill(poisson.GetRandom(), poisson.GetRa>

   TCanvas* c1 = new TCanvas("c1","c1",600,600);
   hist->SetStats(0);
   hist->Draw("colz");
   c1->SetRightMargin(0.13);
}

Thanks, that seems to work. There are some complications with the numbers on the cola palette then overlapping with the Z axis title, but that can be fixed with TAxis::SetTitleOffset().

Yes, you got the idea …