Totally different view of a TGraph2D on two systems

Dear all,

I encountered an unbelievable phenomenon when I refreshed the OS of my PC a few days ago. My data plotted as a 2D graph looked totally strange.
First I thought the data were wrong, but the older system plots the correct graph from the same data. The attached image “old.gif” is the one plotted on the old system, and “new.gif” is on the new system. The latter shows some spikes although none of the Z-values of the data points is above 50 as you can see from the script “graph2d.C”. The difference is also obvious when I plotted the data with other options such as “surf” and “cont4”.
The new system is CentOS 5.4 and the old system is a japanese-localized Linux based on Fedora. I wonder if the external libraries on the new system are leading to the wrong view of the graph because the ROOT versions of the old and new system are the same: 5.24/00b.
Could you tell me what I should look into to fix this problem?
I would really appreciate your help!
graph2d.C (18.6 KB)




I’ll investigate. I let you know.

On my linux box with the latest root version I get the same plot as the one you called " old" … so I guess that’s fine.
I’ll try elsewhere.

My Mac system gives me a picture with peaks also different from yours but also peaks. So I will debug there. It might be a difference of binning … not sure…I’ll investigate and let you know.

It looks like that, at filling time, due to the position of your points which are placed regularly on a grid, several points fall in the same bin in some cases and do not in some others.

That’s a rounding effect. By default the number of bins of the underlying histogram is 40x40. To break the fact the points lie on the regular grid I simply did: graph2d->SetNpx(41);

Thank you very much for your help.
Is there any general solution to avoid this rounding effect?
I thought that just increasing the number of bins could work out, but
setting the same number to Npx and Npy always seems to cause the peaking
regardless of the number.
I also wonder why this effect is system-dependent?

I’ll investigate more and let you know.

It is very well known that you should never fill histograms at the bin boundaries.
When creating histograms holding integers, never create a histogram like

but do

to make sure that your bins are multiple of integer values. Then never fill at the bin edge, but
do something like

Rene

Hello,
For the time being use the workaround I gave you. I traced the problem up to TGraphDelaunay::InterpolateOnPlane. Something can be done there I think but I have not yet found what exactly. I need more time to understand what to do.
O.

Thank you for your advice.

[quote=“brun”]It is very well known that you should never fill histograms at the bin boundaries.
[/quote]
I do not think that explains this case.
The plot screwed up despite setting the binning not to fill the data points at the bin boundaries by

  g2d->SetNpx(41);
  g2d->SetNpy(41);

With the macro you sent me if I do:
g2d->SetNpx(41);
I see the correct plot.
Anyway I am investigating.
I’ll let you know.

Thank you.
I very much appreciate your help.

During my investigations I noticed that if you set a margin to the graph2d:

graph2d->SetMargin(0.1);

Then the peaks disappear. I do not why (yet) but I thought it might be interesting for you.

FYI, I was able to reduce your macro to the minimum needed to show the problem, which is:

{
   TCanvas *c1 = new TCanvas("c1", "c1",0,0,600,600);
   c1->SetTheta(90.);
   c1->SetPhi(0.0001);
   gStyle->SetPalette(1);

   int i=0;	
   TGraph2D *graph2d = new TGraph2D();

   graph2d->SetPoint(i++, 110, 110, 0.0);
   graph2d->SetPoint(i++, -80,  50, 1.0);
   graph2d->SetPoint(i++, -70,  40, 2.0);
   graph2d->SetPoint(i++,-110, -50, 3.0);

   graph2d->SetNpx(9);
   graph2d->SetNpy(9);

   graph2d->Draw("surf1");
   graph2d->SetLineWidth(2);
   graph2d->Draw(" triw p0 same");
}

I am now debugging this one.

[quote=“couet”]During my investigations I noticed that if you set a margin to the graph2d:

graph2d->SetMargin(0.1);

Then the peaks disappear. I do not why (yet) but I thought it might be interesting for you.[/quote]

On my system, the graph view changes with graph2d->SetMargin(0.1), but the peaks still appear…
Anyway, thank you for your help.

This problem in now fixed in the SVN trunk. Thanks for reporting it.

I have checked out and tried the trunk.
Thank you very much for your prompt response! :smiley: