Home | News | Documentation | Download

Set axis range on THStack

hi, im trying to set the range for THStack, i tried

THStack *hs = new THStack("hs", "zd mass");
  hs->Add(h_bkg_zz4lep);
  hs->Add(h_bkg_pph4l);
  hs->Add(h_sig);
  hs->Draw("HIST");
  hs->GetXaxis()->SetTitle("mass of zd (4mu channel)");
  hs->GetYaxis()->SetTitle("Number of Events");
  hs->GetYaxis()->SetRangeUser(0, 100000);

  hs->Draw("HIST");
  
  hs->SetMaximum(h_bkg_zz4lep->GetMaximum()*2);
  hs->SetMaximum(h_bkg_pph4l->GetMaximum()*2);

but its just making no difference, i want to somehow zoom it out alittle on the Yaxis so i get a reading of the peak,

how may i do so?

__
Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22
Platform: mac catalina 10.15.16
Compiler: Apple clang version 11.0.3 (clang-1103.0.32.29)

Do you have typo and want to call SetMinimum in first line?

i followed this thread Get local maximum when using THStack
and added

printf("GlobalMaximum: %f\n",hs->GetMaximum());
  
  TH1 *h = ((TH1*)(hs->GetStack()->Last()));
  
  h->GetXaxis()->SetRangeUser(0,100000);
  printf("LocalMaximum: %f\n",h->GetMaximum());

it works thanks