_ROOT Version: 6.12/06 Platform: Not Provided Compiler: Not Provided
Hi all,
I intend to draw several histograms on the same pad of a canvas, all of them without error bars but one
As a matter of fact, what happens is that ALL of the histograms conform to the choice (to have or not to have error bars) of the last histogram called to be drowned.
Why the previously drawn histograms lose their own “TH1F::Draw” option?
Thanks a lot.
Ignazio
The following is the fragment of code I am using:
auto _legend = new TLegend(0.15,0.65,0.50,0.86);
string hname("7_days_average_Italia_attualmente_positivi_");
for(vector<TH1*>::iterator it=hT.begin(); it!=hT.end(); it++) {
(*it)->GetYaxis()->SetRangeUser(0, maxy);
(*it)->GetXaxis()->SetTitle("Giorni a partire dal 24 Feb. 2020");
if((*it) == hT.front()) {
cout<< hname.compare((*it)->GetName()) << " " << (*it)->GetName() << endl;
if( hname.compare((*it)->GetName()) == 0 )
(*it)->Draw("E 9");
else
(*it)->Draw("HIST P 9");
_canvas->Update();
} else {
cout<< hname.compare((*it)->GetName()) << " " << (*it)->GetName() << endl;
if( hname.compare((*it)->GetName()) == 0 )
(*it)->Draw("SAME E 9");
else
(*it)->Draw("SAME HIST P 9");
_canvas->Update();
}
_legend->AddEntry((*it)->GetName(),(*it)->GetTitle(),"p");
}
_legend->Draw("SAME");
All the the histograms of the vector container have to be drawn;
all of them without error bars, thus calling draw(“SAME HIST P”);
all except one, whose name is “7_days_average_Italia_attualmente_positivi_”, for which I call draw(“SAME E”).
You could take two histograms h1 and h2,
h1-> SetMarkerStyle(20);
h2->SetMarkerStyle(20);
h1->draw(“SAME HIST P”); // no error bar
h2->draw(“SAME E”); // error bar
It’s complicated to use my code, which is a very large one.
Just look at included two figures: in one of them all the histograms exhibit the error bars; in the second no one does.
I needed the first histogram to display error bars by calling Draw("SAME E 9”) for it, while all the remaining not to display error bars, calling Draw("HIST P 9”) for them.
What happens instead is that ALL of the histograms appear without error bars BECAUSE the last histogram was drawn by Draw("HIST P 9”).
As counterevidence, I drew the last histogram by Draw("SAME E 9”) and all the preceding histogram were re-drawn WITH error bars!
Hi,
I used the simple script in the sequel and everything works as it should.
So something is wrong in my large program.
I will search for.
Thanks you.