Putting two plots side-by-side with same Y axis, x axis division?

I am trying to plot two histograms side-by-side sharing the same y-axis labels. My problem is with the x-axis labels. Where the two plots meet in the middle, each of the plots puts a label there and they overlap and/or are cut off. This is, perhaps best shown in the following macro:

int sidebyside() {

  TCanvas *myCanvas = new TCanvas("sidebyside", "sidebyside", 10, 5, 1000, 500);
  
  myCanvas->Draw();
  myCanvas->cd();

  gStyle->SetOptStat(0);

  TPad *myPad1 = new TPad("myPad1", "myPad1", 0, 0, 0.5, 1.0);
  myPad1->SetRightMargin(0.0);
  myPad1->Draw();
  myPad1->cd();
  TH2D *myH1 = new TH2D("myH1", "myH1", 100, 0, 0, 1.0, 2.0);
  myH1->Draw();

  myCanvas->cd();
  
  TPad *myPad2 = new TPad("myPad2", "myPad2", 0.5, 0, 1.0, 1.0);
  myPad2->SetLeftMargin(0.0);
  myPad2->Draw();
  myPad2->cd();
  TH2D *myH2 = new TH2D("myH2", "myH2", 100, 0, 0, 1.0, 2.0);
  myH2->Draw();
  
  return 1;
}

Note that on the x-axis, the left plot’s “1” and the right plot’s “0” overlap. How do I get rid of just these two numbers? It seems like TGaxis or TAxis should be able to help me here, but I haven’t found the correct set of actions.

Thanks,

Paul

ROOT Version: 6.26/00
Platform: Mac OSX 12.3 Montery
Compiler: Apple clang version 13.0.0 (clang-1300.0.29.30)


You can use ChangeLabel to remove the unwanted label.See an example. And an other one.

Thanks, works perfectly