# No y-axis label when using THStack

**URL:** <https://root-forum.cern.ch/t/no-y-axis-label-when-using-thstack/39792>\
**Category:** Newbie\
**Created:** [June 6, 2020, 1:35am UTC](https://root-forum.cern.ch/t/no-y-axis-label-when-using-thstack/39792 "2020-06-06T01:35:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charlie\_Chen](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/charlie_chen/32/21807_2.png) [@Charlie\_Chen](https://root-forum.cern.ch/u/Charlie_Chen)\
**Post date:** [June 6, 2020, 1:35am UTC](https://root-forum.cern.ch/t/no-y-axis-label-when-using-thstack/39792/1 "2020-06-06T01:35:29Z")

</div>

I’m following the very simple THStack tutorial: [https://root.cern.ch/doc/master/classTHStack.html](https://root.cern.ch/doc/master/classTHStack.html) on v6.20/02, and I’m trying to add in axis labels just for this very simple tutorial as a test because I’ve been running into some problems with my own code when adding in axis labels. When using the code below, the x-axis label appears but the y-axis label does not (I’ve also attached a copy of the output plot). Perhaps it’s an issue with margins and the y-axis is being plotted out of the margin.

```auto
{
  THStack *hs = new THStack("hs","");
  TH1F *h1 = new TH1F("h1","test hstack",10,-4,4);
  h1->FillRandom("gaus",20000);
  h1->SetFillColor(kRed);
  hs->Add(h1);
  TH1F *h2 = new TH1F("h2","test hstack",10,-4,4);
  h2->FillRandom("gaus",15000);
  h2->SetFillColor(kBlue);
  hs->Add(h2);
  TH1F *h3 = new TH1F("h3","test hstack",10,-4,4);
  h3->FillRandom("gaus",10000);
  h3->SetFillColor(kGreen);
  hs->Add(h3);
  TCanvas *cs = new TCanvas("cs","cs",10,10,700,900);
  hs->Draw();
  hs->GetXaxis()->SetTitle("X-AXIS");
  hs->GetYaxis()->SetTitle("Y-AXIS");
  cs->Modified();
}

```

Also if someone could inform me of the differences between `gPad->Update()` and `gPad->Modified()`, I couldn’t really find a clear explanation in the documentation.

[THStackAxisLabels.pdf](https://root-forum.cern.ch/uploads/short-url/jNGcjjkJnxzZH6N3T0cFKH1M08.pdf) (13.5 KB)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 6, 2020, 7:57am UTC](https://root-forum.cern.ch/t/no-y-axis-label-when-using-thstack/39792/2 "2020-06-06T07:57:52Z")

</div>

Try:  
`THStack *hs = new THStack("hs", "global title if any;x-axis name if any;y-axis name if any;z-axis name if any");`

Right before “`hs->Draw();`”, add:  
`gPad->SetLeftMargin(0.15);`

Use:  
`gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn`
