Lego plots: coloring only bins with nonzero content

Dear Rooters,

I would like to plot a 2 dim histogram as a lego plot. The latter can have bins colored with a chosen color, by setting “Lego1”. However, I would like that the coloring affected only bins with nonzero content, while leaving bins with zero content “white”, as in the setting “Lego”.

Is that possible?

Have a nice weekend :slight_smile: and thank you,

Do you have some example showing what you want ? The bins with 0 content should be “flat” an you do not see them … I am not sure I undertand what you want. May be THStack may help you ?

I guess he wants something like this:


thank you for your replies. Yes, I want something like what shown by tpochep.
In attachment my example: as you can see there is plenty of empty bins. Well, I would like to have them in white, while having in blue only the “towers” with non-zero bin content.

It should be possible, right?



It should be possible, right?


Olivier already told you, how to do that.
Create your 2d hist (the first, with real data), and the second 2d hist. The second 2d hist must have zero values, where first has non-zero bins, and very small content in bins, where the first has zero content. Set some color for the first hist, and set white color for the second. After that, create THStack and Add(hist1) and Add(hist2). After that call stack.Draw(“lego”).

Attached picture was done with such approach.