Draw a line in a canvas

Hi,

I am puzzled that I do not manage to draw a simple line in a canvas. Attached is a macro, which should draw a colz plot and a line over that. If I turn off the hDef.Draw(“colz”) and just try to draw the line,

   #hDef.SetMaximum(yMax)
    #hDef.SetMinimum(yMin)
    #hDef.Draw("colz")
    chosenEff = 86.0
    line = TLine(chosenEff,yMin,chosenEff,yMax);
    line.SetLineColor(kYellow)
    line.SetLineWidth(2)
    line.Draw()

I just end up with an empty canvas. What am I doing wrong, I wonder?

Thanks,
Maiken
negativity_plotter.py (3.18 KB)

Maiken,

to draw a line, the canvas needs to have a coordinate system to place the line in. Call “c1.Range( 0., -100., 100., 100. )” for example to see the line show up (I came up with those numbers based on the actual values of the TLine’s coordinates in your script).

HTH,
Wim

Fantastic! Thank you very much. The magic lines were these:

chosenEff = 0.86
c1.Update()
c1.Range( 0., -10., 1., 10. )
line = TLine(chosenEff,yMin,chosenEff,yMax);
line.SetLineColor(kYellow)
line.SetLineWidth(2)
line.Draw()