I need to color individual bins of a TH2I histogram.
The histogram is filled with the hit counts of a 2D particle detector (every bin is a channel of the 2D detector and contains the number of hits it has received).
I want to color individual bins based on the time stamp of their first hit.
Something like this:
bin[x][y] -> SetFillColor(RGB(…))
where the RGB parameters are dependent on the timestamp (for example very small times tend towards green, large times towards red).
Another option would be using palettes, I think (though I have to admit, that I haven’t looked into them yet). The main problem, though, is how to color individual bins, I can’t find a way of doing that
Thanks in advance for your time and help!
You plot the histogram with option COL I guess ?
The bin color is defined by its contains mapped on a color map.
I guess you need to define a “friend histogram” with bin contains equal to time stamp of their first hit.
Thanks for your reply!
I forgot to mention, that I want to do it with a lego plot.
If I try “col”, the problem is, that coloring won’t help me because I need to see the “height” of my bins as well.
bin 1 contains 10 hits and has a first hit time of 2000 ps
bin 2 contains 1 hit and has a first hit time of 200 ps
bin 1 should appear as a “high” column (because the count is “large” with 10) and colored in red (because the time is large, too)
bin 2 should appear as a “low” column (count is low) and colored green (time is low)
In that case the only way will be to use several TH2 plotted à THStack
Yes, that seems to be the way to go, thank you very much for the tip!
For anybody else reading this: I found a post that should help building the plot: