I am trying to do something very simple and I am surprised that it doesn’t work… Using ROOT 5.26/00b, I have two histograms which are plotted on the same canvas and I want to draw a horizontal line at y=0 over them. When I do so, the line doesn’t show on top of the histograms, even though it was plotted last (only bits and pieces appears). Anybody know why that is?
I attached the C-dump of the plot, to show you how it looks like.
The line is correctly drawn in the range that you specified, ie between 0 and 1 .
It is likely however that you want to draw a line between xmin=-3 and xmax=8 on your plot.
In this case replace
Ah interesting, so I guess I should have looked more carefully at the C file before sending it. That changes the focus of the problem slightly, but it unfortunately remains. The command I used to draw the line originally is:
Before calling c1->GetUxmin you must update the canvas to force the drawing of the histogram, otherwise
the canvas range will not be updated and the original values [0,1] will be taken. So do as shown below
[code]void test() {
//gROOT->Reset(); //NEVER call this in a named macro
gStyle->SetOptStat(0);
TCanvas *c1= new TCanvas;
TH1D* t0_b_l_h = new TH1D("t0_b_l_h","",110,-3.,8.);
for (int m=0; m<112; ++m) {
t0_b_l_h->SetBinContent(m,5);
}
t0_b_l_h->Draw("e1");
c1->Update();
TLine *l=new TLine(c1->GetUxmin(),3.0,c1->GetUxmax(),3.0);
l->SetLineColor(kBlue);
l->Draw();