Drawing option changes the displayed data!

Hi rooters,

I noticed a very strange behavior: the drawing option I use changes the data that is displayed in the pads. Here is my macro rom the file ‘bug.C’:

void bug()
{
    gStyle->SetPalette(1);
    const char *dirs[] = {    "Kr25AMeV-Zge100", "Kr15AMeV-Zge100", "Kr7.5AMeV-Zge100",
                            "Xe7.5AMeV-Zge100", "Au7.5AMeV-Zge100"
                            };
    TFile *f            = new TFile("histos.root");
    f->cd();
    
    TCanvas *can = new TCanvas("canvas","canvas");
    can->Divide(3,2); 
    int idiv = 0;
    for(int i=0; i<5; i++)
    {
        TString name  = Form("%s/TKEBR",dirs[i]);
        TH2* h      = f->Get(name.Data());
        can->cd(++idiv);
        gPad->SetLogz();
        h->Draw();
        gPad->Update();
    }
}

It fetches histograms in the file histos.root that I attach to this posting and generates a canvas. I attach the gif from that canvas in attachement.

If I replace the line ‘h->Draw()’ by ‘h->Draw(“colz”)’, I get another canvas (see gif attached).

As you can see, a subpad that showed data before, doesn’t anymore, and some that were empty suddenly show data. I check each histogram separately and they all have data. This phenomenon is reproducible, I get exactly the same answer each time I try it (restarting root, repeating it, changing the order,…)

I use ROOT 5.10/00 on RedHat 9.0.

Am I doing something wrong or is this really a bug?

Cheers,
Thomas





histos.root (654 KB)

Remove the line:

Ok, but why? What does it have to do with it? And what if I want a log scale?

You have 2D histograms, you should Logx or Logy instead of Logz.

Sorry, I don’t get it!

Logz is precisely for 2D histograms, not for 1D (since there is no z)! I have a color scale and I want the color scale (the z dimension) to be on a log scale. I don’t see why that would make the data appear or disappear!

That just doesn’t make any sense to me. I always used colz for my color maps and it always worked well when I had more data. The fact that I have to switch to linear scale in some cases is a bug to me! I would have to see what is in the histogram first before I know how to plot it! The script I sent is a simplified version of what I need. When I have tens of histograms to display, I can’t go one by one to adjust the drawing options!

Thomas

When you use no option to draw a 2D histogram (see help) a scatter plot is drawn. What we call " scatter plot" for 2D histograms is a representaion where, in each bin, some random points are drawn to simulate the density. The number of points drawn is proportional to the bin content. This is not a very accurate option in particular in your case where you have very small bins (the bins’ size is close to one pixel !). As you can guess a density of points over one pixel may end up with some rounding problems which explain what you get. Instead of using this option use the option BOX and you will see that it shows the same data as COL.

Thanks, that, at least, explains why some of the data doesn’t appear in the scatter plot.

But there is still another question: how come that some data that appear in the scatter plot do not appear in the colz plot? Whatever the density in the pixel, it should have a color and be plotted, no?

Thomas

Seems to me it is again due to the very small size of your bins (less than a pixel I guess). On the top right plot (color mode) nothing appear but if you zoom a bit using the mouse (on the axis) the data appear. This histogram is 500x450 bins, the window size you have is something like 150 - 200 pixels so you try to plot at least 2 bins per pixels … that is not surprising you have such rounding effects.