I can’t edit the range on y axis of a THStack. I tried to edit the TAxis of the THStack or the TAxis of the entries of the THStack, but nothing changed.
h->GetYaxis()->SetRangeUser(1,2)
or
stack->GetYaxis()->SetRangeUser(1,2)
I can’t edit the range on y axis of a THStack. I tried to edit the TAxis of the THStack or the TAxis of the entries of the THStack, but nothing changed.
h->GetYaxis()->SetRangeUser(1,2)
or
stack->GetYaxis()->SetRangeUser(1,2)
void hstackrange()
{
THStack *hs = new THStack("hs","test stacked histograms");
hs->SetMinimum(200.);
hs->SetMaximum(600.);
TH1F *h1 = new TH1F("h1","test hstack",100,-4,4);
h1->FillRandom("gaus",20000);
h1->SetFillColor(kRed);
hs->Add(h1);
TH1F *h2 = new TH1F("h2","test hstack",100,-4,4);
h2->FillRandom("gaus",15000);
h2->SetFillColor(kBlue);
hs->Add(h2);
TH1F *h3 = new TH1F("h3","test hstack",100,-4,4);
h3->FillRandom("gaus",10000);
h3->SetFillColor(kGreen);
hs->Add(h3);
TCanvas *c1 = new TCanvas("c1","stacked hists",10,10,1000,800);
hs->Draw();
}
[quote=“couet”][code]
void hstackrange()
{
THStack *hs = new THStack(“hs”,“test stacked histograms”);
hs->SetMinimum(200.);
hs->SetMaximum(600.);
TH1F *h1 = new TH1F(“h1”,“test hstack”,100,-4,4);
h1->FillRandom(“gaus”,20000);
h1->SetFillColor(kRed);
hs->Add(h1);
TH1F *h2 = new TH1F(“h2”,“test hstack”,100,-4,4);
h2->FillRandom(“gaus”,15000);
h2->SetFillColor(kBlue);
hs->Add(h2);
TH1F *h3 = new TH1F(“h3”,“test hstack”,100,-4,4);
h3->FillRandom(“gaus”,10000);
h3->SetFillColor(kGreen);
hs->Add(h3);
TCanvas *c1 = new TCanvas(“c1”,“stacked hists”,10,10,1000,800);
hs->Draw();
}
[/code][/quote]
thanks, it’s not very intuitive, and the maximum is not correct: it is near 630 and not 600
It is like the simple histograms.
gStyle->SetHistTopMargin(0);
[quote=“couet”][quote]
it’s not very intuitive.
[/quote]
It is like the simple histograms.
[/quote]
It’s not intuitive that GetYAxis()->SetRangeUser works for TH1F, but not for THStack
[quote=“couet”]
gStyle->SetHistTopMargin(0);[/quote]
perfect, thanks