Black style (lines) on top of colored areas?


I have a TH1F plot merged from several other TH1F plots. So far I used different colors for each area (Sub-TH1F). Now I want some styles in addition to make such plots black/white printer safe. Because some plots are in front of others I can not just use a “colored style” because then the resulting plot is a mess.

So my question is: How can I combine solid color areas with black line styles on top of it (for example lines with diff. angles)?


Use myhist.SetFillStyle(style);
where style is one of the styles available at:


Hi Rene!

Thanks for your quick reply. I basically know the parameter SetFillStyle(). I tried several options but the problem I still have is that I can not combine a solid color area with black lines!
For example:


gives me a solid red area. When I afterwards apply a style, e.g.:


the solid area is gone and only the mash has the color red. Perhaps you can give me a short example of how the parameter is used so that I get a black mesh on a solid red surface (instead of a red mash on a white background, see attached figures)?

Thanks a lot!

You have to draw your histogram twice as illustrated in the session below;

Root [1] hpx.SetFillColor(kRed) Root [2] hpx.SetFillStyle(1000) Root [3] hpx.Draw() Root [4] TH1 *h2 = (TH1*)hpx.Clone("h2") Root [5] h2.SetFillColor(1) Root [6] h2.SetFillStyle(3309) Root [7] h2.Draw("same")

Hi Rene!

Thanks, that works fine for TH1 objects.

But a problem appears (at least for me) if one tries to use the histograms with THStack (The “draw” option there does not help) .

Also if one uses a TLegend, one either gets the coloured area from the first histogram (using TLegend::AddEntry() with option “F”) or the mash from the second histogram. Any ideas?

I think it would be helpful to have some new SetFillStyle() options to combine colored ares with styles on top into a single histogram. Is that possible?


When using a THStack you do not need to specify the option “draw”, it is implicit. Note that when adding an object to the stack, you can specify a drawing option.

Concerning your problem with TLegend could you send me a short script showing the problem? This should not happen if you point to 2 different objects.


Hi Rene!

Thanks for your quick answer (once again :slight_smile: )!
What I meant is that I did not succed in using several of those plots (with a colored area and a black mash) together in a THStack. Do I have to add both histograms each (one with the colored area and the cloned one with the mash)? Perhaps you can give a short example…

What concerns the TLegend. If I start from this example:

Root [1] hpx.SetFillColor(kRed)
Root [2] hpx.SetFillStyle(1000)
Root [3] hpx.Draw()
Root [4] TH1 *h2 = (TH1*)hpx.Clone("h2")
Root [5] h2.SetFillColor(1)
Root [6] h2.SetFillStyle(3309)
Root [7] h2.Draw("same") 

what I typically do is:

leg = new TLegend(0.7,0.6,0.9,0.9);

But then the small box in the legend only contains the red color. If I do:


instead, I only get a box with the style (mesh) within the legend. I can not refer to both histos at the same time, can I? This is what I meant by saying that this is different from the situation where both histograms are drawn into one pad. Or did I miss something?

Thank you very much!

With a THStack, you should do something like:

{ hpx.SetFillColor(kRed); hpx.SetFillStyle(1000); TH1 *h2 = (TH1*)hpx.Clone("h2"); h2.SetFillColor(1); h2.SetFillStyle(3309); THStack s("s","s"); s.Add(hpx); s.Add(h2); s.Draw("nostack"); }

I see the problem with TLegend. Of course my suggestion does not work because you would like the legend to refer to one object only.
I will see with Olivier, once he will be back, how to solve the general problem using one object only.


Hi Rene!

That would be great! Thanks a lot!



Happy new year! Are there any news to this topic?


I will look at it

To solve this question I guess we should provide a way of setting the background color of a filled area painted with hatches. Right now hatches and patterns are transparent, the color of the fill area defines the color of the hatches.

One possible way would be to have a new fill area attribute like SetHatchesBackgroundColor().

An other possibiliy would be to define some special encoding of the FillColor attribute like 1000*hatches_background+fill_color.

This requires careful thinking because TAttFill is widely used.