Color on error bands on TH1 histogram


I wonder if it is possible to set a specific color and fill on the error band of a TH1F histogram, using the error draw option e2. I would like to show the histogram with line in one color and no fill, and the error band, let’s say in a grey hashed shade over the histogram.


Draw first the error band and then the histogram on top as a line using the option SAME.


thanks for your reply.

You mean I should set the histogram fillcolor and fillstyle, and that the error band then will use this automatically? My experience is that I instead do not only get colors and fills on the error band, but the rest of the histogram also, and this is what I want to avoid.

Any solution for this? I.e let’s say a histogram without fill, and with let’s say blue line, and an errorband on this histogram which is hashed grey.


If you what to draw the same histogram on the same picture with different TAttFill attributes you have to Clone this histogram and set the different attributes on each instance of the histogram.

But I understood you want to first draw a filled area (the band) on which the TAttFill attributes apply, and then you want to draw the histogram as a line on which the TAttLine attributes apply. In this case you do not need to make a clone (in principle) because they are not the same kind of attributes. But you still need to draw twice as I said previously.

If you have a small macro showing you problem it might be easier to help you further.

Yes, a macro is attached showing 2 cases of what I don’t want, and then showing the case where the error bar is as I wish, but where there is no histogram line.

errortest.C (713 Bytes)

void errortest(){
  TH1F *h = new TH1F("h","",10,0,10);


  for(int i=0; i<9; i++){
  h->Draw("hist L same"); // you missed the option L


but this gives me the plot attached which is not really what I want? :slight_smile:

see your script modified in the attachment

errortest.C (717 Bytes)

Great, thank you, it was the DrawCopy function then that is needed.

Have a good day