I’m drawing an histogram whith this command:
t->Draw(“ntracks >> h(45,0,45)”,“ntracks>0”);
After this I want to add entries to the first bin by the command:
But when I draw the histogram with the command:
the statistic box always shows the “Entries” before the call to the command AddBinContent.
How can I have the correct number of entries in the statistic box?
I’m drawing a 1-D histogram which bin content ranges from 0 to 120, so the Y axis has more or less this range; but later I want to draw an histo on the same canvas which bin content is from 0 to 140, so I cannot see some bins for which the bin content exceeds the limit on Y axis given by the first histogram.
How can I expand the range of the Y axis?
Thanks a lot to both of you for the fast and clear reply!
[quote]-setting the maximum along y
see also THStack that takes care of computing automatically the best scale for a set of histograms.[/quote]
[quote]-first problem; update the stats box
after SetBinContent, add
I’ve done like this:
root  t->Draw("ntracks >> h(45,0,45)","ntracks>0")
root  h->AddBinContent(1,435)
root  gPad->Modified()
root  h->Draw()
but the number of entris after the AddBinContent call is always the same as before (1145) and not 1580 as I should expect…
The second argument to AddBinContent is not a number of entries, but the weight such that the new bin content will be old_bin_content+weight. This function does not increment the number of entries.
If you want to increment the bin content and also the total number of entries in the histogram, you should do something like
int n = t->Draw("ntracks >> h(45,0,45)","ntracks>0");
double binc1 = h->GetBinContent(1);