Problems with TGraph2D and pcol (and zcol)

I have been using TGraph2Ds to visualize a set of points, but am seeing several problems when viewing
them with both the pcol and zcol options. I am using 5.28.00b.

Using the following snippet

Double_t dz[10] = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.};
Double_t x[10] = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.};
Double_t y[10] = {.4,.5,.1,.3,.8,.4,.5,.6,.2,.1};
TGraph2D hgdzval("hgdzval","dzval",10,x,y,dz);
hgdzval.Draw("zcolpcol");

I get the following image
c1a.pdf (15.2 KB)

Problem 1: the colors don’t show up on the Z color scale

Playing around I tried
hgdzval.Draw(“zcol”) and then after that another time with hgdzval.Draw(“zcolpcol”)
Now the z color scale shows the colors:
c1b.pdf (15.2 KB)

Problem 2: By default the z color scale is located off the edge of the pad. Perhaps it is possible to resize
parts of the pad so the color scale is all visible, but it would be very nice if the root defaults made that so.
I checked that I’m not changing any of the pad margins in my rootlogon, by the way.

Problem 3: Another issue is that it doesn’t seem to be possible to resize the histogram frame interactively,
with a TGraph2D - I can’t see where to “grab” onto it in the pad, you always get the icon to rotate the frame.

Lastly, I moved the z color scale to where I can see it, and now I want to rescale it. What I hoped would happen is that if I interactively zoom on the z color scale, that the colors would remap to the new limits
and that the color on the points would also rescale. This would be very useful behavior. But what happens looks buggy.

Problem 4: The z-axis on the frame changes correctly, and the numbers on the z color change, but the colors on the points don’t remap, and the colors on the z color scale are confused. See:c1c.pdf (15.1 KB)

Once this is fixed it would also be handy to adjust the color zoom by a script - how is that done with a TGraph2D?

The pcol option is potentially very useful - so thanks much for your help in addressing these issues.

Aaron

To get the right palette simply do:

hgdzval.GetHistogram()->SetContour(10);

I will make this contours level definition automatic.

I will post the fix soon.

You can change the right margin. The new " Modern" style does it better by default.

That’s the same with histo plotted lego and surface. you can do it with a script.

I agree.

it is because the palette as been primarily implement for histograms with option col or surf1 and for these options the palette is always remapped from the lowest color to the highest in the palette (after a zoom)…

Now fixed.

I am trying again to use TGraph2Ds with the pcol option, now with ROOT 5.32/00

The script I previously posted gives correct results - the colors scale match the colors used for the markers - see the first attachment.

pcol-example1.pdf (15.5 KB)

However, if I change the z-axis minimum or maximum, either with the cursor or by .SetMinimum and .SetMaximum the marker colors don’t match the scale, see the second attachment.

pcol-example2.pdf (15.1 KB)

Here is what I did:

Double_t dz[10] = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.};
Double_t x[10] = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.};
Double_t y[10] = {.4,.5,.1,.3,.8,.4,.5,.6,.2,.1};
TGraph2D hgdzval(“hgdzval”,“dzval”,10,x,y,dz);
hgdzval.Draw(“zcolpcol”);
hgdzval.SetMaximum(7.5)
hgdzval.SetMinimum(2.5)
hgdzval.Draw(“zcolpcol”);

the pcol option of TGraph2D would be very useful if this behavior were fixed,

thanks, Aaron

I’ll check

This is now fixed in the svn trunk.

I had the same problem as roodman when using 6.06/09, but when I change the minimum or maximum, the points do not match the correct color in the z-axis. How do I get this fix?

I would suggest you try with a more recent ROOT version. Do you have a small macro reproducing the problem ? .

Please in the future do not use old posts to ask question. This one was finished since 6 years …

Hi @couet, thanks for the reply. The problem I had was exactly the one from here:


I managed to switch to root 6.12/07, and I managed to get it working as expected.

1 Like