How to stop drawing lines on histo bins with zero content


I have made profile histogram from 2D histogram. Now if i am trying to draw it:
hist11->Draw(“HIST PL”);
It draws the line and the marker through the whole X range of the histogram including empty bins at the end. Like this:

However, if I use:


It draws only marker for the filled bins but does not connect them with the line.
Like this:
My goal is to conect markers with the line bur ignore empty bins at the end.

can somebody please tell me what I am not doing?



To draw the errors AND the line you should do 2 passes:

 hist11->Draw("L SAME");

Thanks! It did work with the slight modification!

hist11->Draw("PE"); hist11->Draw("HIST L SAME"); [/quote]

However, it still draws the line through the zero bins at the end. (see )

Can you help get rid of it?


You got this line because your data are stored in an histogram. Therefore with option line L, C etc … all the bins are drawn, even the empty ones. To draw only a line through the few points you have, the simplest would be to use a TGraph and draw it on top of the histogram using option L. Do you know how to put these few points in a TGraph ?
Also, an other simple solution could be to set the histogram minimum to 0.