Equalise axis title offset

Consider this example:

void differentsizes2()
{
  gStyle->SetLabelFont(43,"XYZ");
  gStyle->SetLabelSize(12,"xyz");
  gStyle->SetTitleFont(43,"XYZ");
  gStyle->SetTitleSize(18,"xyz");
  gStyle->SetTitleOffset(1.1, "xyz");

  TCanvas * c = new TCanvas;

  TPad * pad1 = new TPad("pad1", "pad1", 0.0, 0.2, 1.0, 1.0);
  pad1 -> Draw();
  pad1 -> cd();
  TH1F * h1 = new TH1F("h1;", "h1; x; y", 10, -1.0, 1.0);
  h1 -> Draw();
  c -> cd();

  TPad * pad2 = new TPad("pad2", "pad2", 0.0, 0.0, 1.0, 0.2);
  pad2 -> Draw();
  pad2 -> cd();
                                                                                                                                                                        
  TH1F * h2 = new TH1F("h2", "h2; x; y", 10, -1.0, 1.0);
  h2 -> Draw();
}

The output is:

The title offset is equal for the Y axis but the equalisation fails for the X axis. What is wrong?


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Nothing is wrong, the title offset is a distance relative to the Y size of the pad. Your two pads have very different Y size . You should set the offset separately.

Like this:

pad2 -> SetBottomMargin(0.3);
h2 -> GetXaxis() -> SetTitleOffset(pad1 -> GetHNDC()/pad2 -> GetHNDC());

?

As you wish. What is working for you …

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.