Move/resize TF2 plot and palette

Dear all,
I have a very simple macro to draw a T2F function; please find it in attachment. tf2.C
It produces a canvas which I save as a pdf and I attache as well. tf2.pdf
As you can see the palette is partially out of the canvas. I have tried using the mouse to resize
the T2F plot but it does not allow me to resize it or move it. Resizing the palette is a cumbersome
workaround. I have tried some methods of TCanvas to resize it but they do not work for me and plus I believe the thing to be resized is the canvas as it contains the palette as well.

Am I missing something? Any help will be greatly appreciated.

Regards,
Marco Bomben


ROOT Version: 6.11/02
Platform: OS X
Compiler: Apple LLVM version 10.0.0 (clang-1000.10.44.2)


Somewhere BEFORE the first “Draw” add: gPad->SetRightMargin(0.13);

{
  TF2* fff = new TF2("fff","5.5e+15*TMath::Gaus(x,-0.6,7.30,0)*TMath::Gaus(y,1.5,6.24,0)+9.0e+15*TMath::Gaus(x,-0.5,8.34,0)*TMath::Gaus(y,0.9,6.93,0)",-10,10,-8.4,8.4);
  fff->SetTitle(";X [mm]; Y[mm]; #Phi [n_{eq}/cm^{2}]");
  fff->Draw("colz");
  gPad->SetRightMargin(0.13);
}

@couet How about you add gPad->Update(); right AFTER “Draw” in your example. :face_with_raised_eyebrow:

Well in that particular it worked without for me. I ran this example as it is.

Thanks a lot you both!
Both solutions work for me, even without adding a ‘gPad->Update();’ after the ‘Draw’ in @couet example.

Thanks and regards,

Marco Bomben

My point was that “updating” the pad (between “Draw” and “SetRightMargin”) would immediately break Olivier’s example (call it a “feature”, not a “bug”). You should always set appropriate “margins” BEFORE you draw anything.

Yes and the example will become:

{
  auto *C = new TCanvas();
  TF2* fff = new TF2("fff","5.5e+15*TMath::Gaus(x,-0.6,7.30,0)*TMath::Gaus(y,1.5,6.24,0)+9.0e+15*TMath::Gaus(x,-0.5,8.34,0)*TMath::Gaus(y,0.9,6.93,0)",-10,10,-8.4,8.4);
  fff->SetTitle(";X [mm]; Y[mm]; #Phi [n_{eq}/cm^{2}]");
  C->SetRightMargin(0.13);
  fff->Draw("colz");
}

Thank you both again. I really appreciate this insight:

You should always set appropriate “margins” BEFORE you draw anything.

This topic can be closed now for what concerns me.
Regards,
Marco Bomben