TGraph2D colz Option

Hello, I am drawing a TGraph2D using the “colz” option, but it seems to be interpolating between my actual data points. I am looking for a drawing option that will produce a 2D colour plot with the colours corresponding to the Z axis values, is there such an option? It looks like “PCOL” is close to what I want, but I don’t want it to look 3D, I just want the X vs Y graph and colour for Z. Ideally the points would be rectangles such that the whole graph would be coloured like when using “colz”, but with only one rectangle per data point.


A brutal fix … My2DGraph->SetMarkerStyle(21); // style 21 = "full square" My2DGraph->SetMarkerSize(1.0); // size 1.0 = 8 pixels on the screen My2DGraph->Draw("PCOL"); gPad->Modified(); gPad->Update(); // make sure it's really (re-)drawn gPad->GetView()->TopView();

That is indeed brutal, and would not work too horribly with equally-spaced data points. Unfortunately I’d have to calculate the size of each square based on the distance to the next ones…

Having read more about how TGraph2D are drawn, it looks like for any draw option supported by TH2*, a triangle-interpolation is done to first create a TH2*, then it is drawn. Is there a way to control this interpolation? Is there another method for converting TGraph2D into TH2*? In my case, I’d want bin centers at the data point values, with widths tuned to that the bin boundaries are equidistant between the data points. Then bin contents would then just be the Z value. I guess I could write my own hack to do this, but it seems like it might be already included… any ideas?


Well, this might look better for you … My2DGraph->SetMarkerStyle(20); // style 20 = "full circle"
If you really know that your data span over some kind of a regular “rectangular grid”, then, instead of a TGraph2D, create a “variable bin size” TH2 or a TH2Poly (you could use the “COL[Z]” drawing option then).
Note that, in general, usually, TGraph2D data will not form any “rectangular grid”. That’s why the “Delaunay triangulation” must be used.