I’m having the problem of drawing a 2D histogram with fractions created from numerator->Divide(denominator), after the numerator in that fraction has already been drawn. The z axis label and numbers are still the values of the numerator, rather than the fraction. Both are drawn with “colz”. This feature doesn’t appear if I don’t draw the numerator first. I attach some code and the root file with histos.
As written in the code, if the numerator is not drawn first, the fraction comes out fine.
I’m aware that similar problems have been reported in sft.its.cern.ch/jira/si/jira.is … -7168.html, but none of them are helping me. I’m getting this problem with pyROOT as well, and creating a new canvas does not help. file.root (522 KB)
OK, this works, and after closer inspection it seems it’s the DrawClone that does it (I could comment out the other new things without altering the result). But this is a simplified example, I want this to work in my plotting scripts generally. In those, I pass histograms to a macro which creates a canvas, plots the histogram and saves the figure. I could get around this temporarily by calling “DrawCopy” inside that macro rather than “Draw” (“DrawClone” produced an empty plot, even after calling gPad->Update() or canvas->Update()). But is this intended to get fixed? It’s clearly not working as you’d expect/want it to.
Lorenzo and I had a closer look to your question. We will come back to it. Basically the command:
hnum->Clone(“fraction”); does copy of the palette also (which is part of the histogram). We need to looks at this closer. instead do:
TH2F* h_frac =new TH2F(*hnum);