I’m following the very simple THStack tutorial: 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.
{
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 (13.5 KB)