I’m using a TH2F container to visualize some data, with the “COLZ,TEXT,ERROR” option. Most things are fine: the values + errors are printed ok, I can style with SetPaintTextFormat, SetMarkerSize and SetMarkerColor, etc.
I’m wondering however whether there is a possibility to not print the text on the bins that are empty. For example I now have several where I get 0.00 ± 0.00 printed, but I would strongly prefer to not have anything printed there.
For TH1 there are the P and P0 options handling this, but can this be done for TH2 as well?
I hope this question is clear like this, but please let me know if I need to provide example code.
I didn’t immediately want to believe you, but you’re supposed to know more about ROOT than most of us do, so I went to investigate again. I tried opening my ROOT file, and indeed, when I draw interactively from it, my empty bins don’t get text printed on them. Also when I interactively save these plots, the result is as I would like.
However, when I save my canvases in my pyroot script with canvas.SaveAs(“filename.png”) (or pdf), there are 0.00 ± 0.00’s on my plot.
Can you guess where this might be going wrong?
I was trying to produce one. It’s not so easy to take a chunk out of my production script that I can share, and any minimal example I had tried so far doesn’t have to problem.
I did however find the culprit. If I disable my style.C the problem disappears. In there is the entry:
gStyle->SetHistMinimumZero(kTRUE)
If I remove that, the 0.00 ± 0.00 disappear. I would however like to keep that setting for the styling of my 1D histograms…
Attached is a minimal C macro with this setting activated. test.C (366 Bytes)