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

**URL:** <https://root-forum.cern.ch/t/putting-two-plots-side-by-side-with-same-y-axis-x-axis-division/49239>\
**Category:** Newbie\
**Tags:** graphics, root\
**Created:** [March 17, 2022, 4:19pm UTC](https://root-forum.cern.ch/t/putting-two-plots-side-by-side-with-same-y-axis-x-axis-division/49239 "2022-03-17T16:19:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![preimer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@preimer](https://root-forum.cern.ch/u/preimer)\
**Post date:** [March 17, 2022, 4:19pm UTC](https://root-forum.cern.ch/t/putting-two-plots-side-by-side-with-same-y-axis-x-axis-division/49239/1 "2022-03-17T16:19:06Z")

</div>

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:

```auto
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)

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 17, 2022, 4:28pm UTC](https://root-forum.cern.ch/t/putting-two-plots-side-by-side-with-same-y-axis-x-axis-division/49239/2 "2022-03-17T16:28:11Z")

</div>

You can use [ChangeLabel](https://root.cern/doc/master/classTAxis.html#afc19787e727c9e3c85be72eba03338da) to remove the unwanted label.See [an example](https://root.cern/doc/master/classTGaxis.html#GA10a). And [an other one](https://root.cern/doc/master/classTGaxis.html#a8ef5ba035d846add3902cd714336eaac).

---

<div class="post-metadata">

**Author:** ![preimer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@preimer](https://root-forum.cern.ch/u/preimer)\
**Post date:** [March 17, 2022, 5:00pm UTC](https://root-forum.cern.ch/t/putting-two-plots-side-by-side-with-same-y-axis-x-axis-division/49239/3 "2022-03-17T17:00:40Z")

</div>

Thanks, works perfectly
