but in this plot produced by the following macro, the y=0 line still exists when there’s no negative content.
void test1 () {
gROOT->SetStyle("ATLAS");
ROOT::RDataFrame rdf(100);
auto rdf_x = rdf.Define("x", [](){ return gRandom->Rndm(); }).Define("x1", "1+x").Filter("x>0 && x1>0");
const int nbins = 20;
auto h = rdf_x.Histo1D({"h","",nbins,0,1}, "x");
auto h1 = rdf_x.Histo1D({"h1","",nbins,1,2}, "x1");
auto hs = new THStack("hs","");
hs->Add((TH1D*)h->Clone("hc0"));
hs->Add((TH1D*)h1->Clone("hc1"));
auto c = new TCanvas("c");
hs->Draw("PLC NOSTACK");
hs->SetMaximum(10);
hs->SetMinimum(-1);
}
void test1 () {
gROOT->SetStyle("ATLAS");
ROOT::RDataFrame rdf(100);
auto rdf_x = rdf.Define("x", [](){ return gRandom->Rndm(); }).Define("x1", "1+x").Filter("x>0 && x1>0");
const int nbins = 20;
auto h = rdf_x.Histo1D({"h","",nbins,0,1}, "x");
auto h1 = rdf_x.Histo1D({"h1","",nbins,1,2}, "x1");
auto hs = new THStack("hs","");
hs->Add((TH1D*)h->Clone("hc0"));
hs->Add((TH1D*)h1->Clone("hc1"));
auto c = new TCanvas("c");
hs->Draw("NOSTACK");
hs->SetMaximum(10);
}
The axes are thicker for pdf and ps files, making it more difficult to notice. But, if I switch antialiasing off, the line at zero is clearly as “thick” as the rest of the histograms.
@couet This works because you overwrite the “ATLAS” style setting with “SetHistLineWidth” (the additional line at zero is then as thick as the axis, so you do not see that it is still there).
hs->Draw("NOSTACK");
hs->GetHistogram()->SetLineWidth(0); // "remove" the line at zero
hs->SetMaximum(10.);
hs->SetMinimum(-1.);
gPad->Modified(); gPad->Update();
@couet It seems to me that this “fix” should be added to the THStack painter (so that the line at zero is automatically not drawn when “NOSTACK” is used).