THStack without line at 0

Hi guys,
I was woundering on how to remove the line at 0 in a THStack.
I already found that the drawoption “0” is the sollution but now I would like to combine it with the “nostack” drawoption. I tried it with “,” and " " as seperators but it didn’t work.
Any advice?
Thanks for your help.
Christian

can you provide a small macro showing what you mean ?

Hi guys,
here a small script which should demonstrate the issue.
For the draw option “nostack” I receive the plot with a blue line at 0;
In case of the default draw the line only apears for the parts of the stack greater than 0.

Here it is mentioned that “0” as draw option should be used to remove the line.

Unfortunatelly this didn’t work.

So there are actually two problems:

  1. how to get rid of the line at 0
  2. combine 1. with the nostack draw option

Thanks for your help

Christian

{
  TH1F* th1 = new TH1F("th1","th1",5,0.5,5.5);
  th1->SetLineColor(1);
  th1->SetLineWidth(2);

  TH1F* th2 = new TH1F("th2","th2",5,0.5,5.5);
  th2->SetLineColor(2);
  th2->SetLineWidth(2);

  th1->Fill(1,1);
  th1->Fill(2,-1);
  th1->Fill(3,1);
  th1->Fill(4,-1);
  th1->Fill(5,1);

  th2->Fill(1,2);
  th2->Fill(2,-2);
  th2->Fill(3,2);
  th2->Fill(4,-2);
  th2->Fill(5,2);

  THStack* ths = new THStack();

  ths->Add(th1);
  ths->Add(th2);
  

  TCanvas* c =  new TCanvas("stackTest","stackTest",700,400);
  c->cd();
  ths->Draw("nostack");
  //ths->Draw("");

}

May be something like that will help.
Also it is clearer to show where the data actually are.
stackTest.C (2.96 KB)

Hi Couet,
thanks for your answer.
I just changed

ci = TColor::GetColor("#ffffff");

in your solution and now the line is still there but not visible anymore.
For me this is fine, I was somehow expecting that it would be possible to actually remove the line.

Anyway this solution works for me.

Thanks for the help.

Christian

Hi,

this is an old post I see.

Is there really no other way to remove the line at 0 when drawing with THStack?

Kind regards
Maiken

Hi Maiken,

so far I didn’t find another solution.
I am still changing the color to make it “disapear”.
Keep us posted in case you find another solution.

Cheers,
Christian

{
  TH1F* th1 = new TH1F("th1","th1",5,0.5,5.5);
  th1->SetLineColor(1);
  th1->SetLineWidth(2);

  TH1F* th2 = new TH1F("th2","th2",5,0.5,5.5);
  th2->SetLineColor(2);
  th2->SetLineWidth(2);

  th1->Fill(1,1);
  th1->Fill(2,-1);
  th1->Fill(3,1);
  th1->Fill(4,-1);
  th1->Fill(5,1);

  th2->Fill(1,2);
  th2->Fill(2,-2);
  th2->Fill(3,2);
  th2->Fill(4,-2);
  th2->Fill(5,2);

  THStack* ths = new THStack();

  ths->Add(th1);
  ths->Add(th2);
  
  TCanvas* c =  new TCanvas("stackTest","stackTest",700,400);
  c->DrawFrame(0.5, -3.,5.5, 3.);
  ths->Draw("samenostack");
}