Z scale and color pallete

Dear Rooters,

In a 2D plot, the z count starts from 10^-2 (with the option ‘colz’).
When I start it from 1 using hist->SetMinimum(1), the color pattern changes which is obvious. How to conserve the same color pattern (of kRainbow=55)?
I mean is there anything I can change in the ‘Gradient Color Table’ I am using (kRainbow=55)?

Hi,

I do not understand very well the question. Perhaps @couet can help here.

Best,
D

Yes, when you draw a 2D histogram the palette is displayed according to the full dynamic of the histogram. One simple way for your case might be to create a copy of the original histogram in which you will set (with SetBinContent) all the bins having a content <=1 to 1.

Thanks @couet . I am directly reading/taking the 2D histograms from other root files (not by TGraph etc.), in my program. In such case, how can I set all the lower bins having content <=1 to 1?

Could you please give me an example of the solution you suggested using `SetBinContent’ here?

auto f = new TFile ("your_file.root");
TH2F *h = (TH2F *)f->Get("your_hist");
TH2F *hc = (TH2F*)h->Clone();
int nbinsX = h->GetNbinsX();
int nbinsY = h->GetNbinsY();

for (int i = 1; i <= nbinsX; i++) {
    for (int j = 1; j <= nbinsY; j++) {
       if (hc->GetBinContent(i,j) < 1) hc->SetBinContent(i, j, 1.0);
    }
}
hc->Draw("COLZ");

Thanks @couet by doing that the background color turns green. How to restore the pad-background color to white?

As the bins are not empty the “background” colour correspond to the minimum of the histogram: 1 in your case.

May be you need an other technique and define your own palette as described here. You will not need to change this histogram in that case,