Reset THStack axis title

Hi,
I realized that axis titles of a THStack object may not be easily reset by calling:

hs->GetXaxis()->SetTitle("Reset X title");

So I have to reset the THStack axis title by a indirect way. Here is an example:

test_THStack_title() {

  TH1D * h = new TH1D("h", "", 100, -1, 1);
  h->FillRandom("gaus", 10000);
  THStack * hs = new THStack("hs", "test; x title; y title");
  hs->Add(h);

  hs->Draw("nostack");

  hs->GetXaxis()->SetTitle("Reset X title"); //no effect

  c1->Update();
  c1->Modified();

  TH1 * hist = (TH1*)hs->GetHistogram();
  hist->GetXaxis()->SetTitle("Reset X title");
  hist->Draw("");
  hs->Draw("nostacksame");
}

I am wondering if there is another simple way to reset the titles? Thanks.

Cheers,
Zhiyi.

That’s right. You should do:

hs->GetHistogram()->GetXaxis()->SetTitle("Reset X title");