Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill attribute is not fully reflected in THStack #6997

Closed
akira-okumura opened this issue Jan 7, 2021 · 4 comments
Closed

Fill attribute is not fully reflected in THStack #6997

akira-okumura opened this issue Jan 7, 2021 · 4 comments
Assignees
Labels

Comments

@akira-okumura
Copy link

root [0] auto h1 = new TH1D("h1", "h1", 50, -5, 5)
root [1] auto h2 = new TH1D("h2", "h2", 50, -5, 5)
root [2] h1->FillRandom("gaus")
root [3] h2->FillRandom("gaus")
root [4] auto hstack = new THStack("hstack", "")
root [5] hstack->Add(h1)
root [6] hstack->Add(h2)
root [7] h1->SetFillStyle(0)
root [8] h2->SetFillStyle(0)
root [9] hstack->Draw("c")
root [10] gPad->SetGrid()

The above code draws correct h1 and h2 distributions, but the fill attribute 0 is not fully reflected in the canvas.

image

Please also see this thread in the ROOT forum.
https://root-forum.cern.ch/t/fill-attribute-is-not-fully-reflected-in-thstack/42987

@couet couet self-assigned this Jan 7, 2021
@couet
Copy link
Member

couet commented Jan 7, 2021

Thanks. Here is the code re-formatted (easier to copy/paste in a macro)

{
   auto h1 = new TH1D("h1", "h1", 50, -5, 5);
   auto h2 = new TH1D("h2", "h2", 50, -5, 5);
   h1->FillRandom("gaus");
   h2->FillRandom("gaus");
   auto hstack = new THStack("hstack", "");
   hstack->Add(h1);
   hstack->Add(h2);
   h1->SetFillStyle(0);
   h2->SetFillStyle(0);
   hstack->Draw("c");
   gPad->SetGrid();
}

@jblomer jblomer added the bug label Jan 12, 2021
@couet
Copy link
Member

couet commented Jan 26, 2021

Actually this behaviour is documented here. One should use the option "noclear" . May be the painting option should be made more visible at the top of the THStack class. Just do:

   hstack->Draw("c noclear");

@couet
Copy link
Member

couet commented Jan 27, 2021

THStack documentation has been clarified.

@couet couet closed this as completed Jan 27, 2021
@akira-okumura
Copy link
Author

Thank you Olivier. I did not expect that THStack had drawing options in addition to those for TH1.

I do not understand why the "noclear" option is needed.

If the patterns used to draw the histograms in the stack are transparents, then the plot behind will be visible.

Always enabling "noclear" will not change the behaviors of all use cases, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants