How to color a specific bin

Hi All,
I have a blue 2D histogram. I want to paint some of the bins in red. How can I do it?

Hi @Alex_Zhang,

thank you for your question. Maybe this tutorial is what you need: ROOT: tutorials/hist/multicolor.C File Reference ?


1 Like

@mczurylo example is good ! Are you using a lego representation ? if not can you be a bit more specific ? which representation are you using ? may be you have a small reproducer ?

The histogram I obtained is like this.

I want the deep colour parts to turn red.The example you gave doesn’t seem to match my expected results very well.

This is the old scatter plot (SCAT) option. It is now deprecated and not recommend to be used. Can you try to draw your histogram, using the option COL or COLZ ?

I drew it using TH2D. The raw data is a series of coordinates of X and Y. I just want one part of the histogram to change color, while the other areas remain unchanged. Can this be achieved?

What do you get if you do h->Draw("colz") ? h being your TH2D.

colz histogram:

But I just want a few of bins to change the color, and keep the rest unchanged.

If the bins you want to color are above a certain value, you can define your own palette with 2 colors only: above and below the value.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.