Tick marks overwritten by histogram with solid fill color

I find that if I draw a histogram with a solid fill color first, the tick marks on the axes are displayed in front of the histogram. However, if I draw a histogram with no fill first, followed by a solid histogram, the tick marks are covered. I have thus far not been able to recover the tick marks that are covered by the solid histogram.

It is convenient for me to plot in this order because I have a histogram with no fill that has a wider vertical range and error bars that I want to include in a plot with a solid color histogram. By plotting the no fill histogram first, the vertical axis range is conveniently set automatically.

Here is an example in which the tick marks are covered:

TH1F *h1 = new TH1F("h1","test hstack",100,-4,4); 
root [1] h1->FillRandom("gaus",20000);                     
root [2] TH1F *h2 = new TH1F("h2","test hstack",100,-4,4); 
root [3] h2->FillRandom("gaus",15000);                     
root [4] h1->Draw()                                        
root [5] h2->SetFillColor(kBlue)
root [8] h2->Draw("same")

If the order of the Draw statements is reversed, the tick marks are visible. Trying another h1->Draw() command at the end does not seem to recover the tick marks.

Thank you,
Adrian

gPad->RedrawAxis();

ā€¦ is the answer to your problem.

1 Like