TGraph2D not-interpolated and not TH2F

I saw a similar question here, but the answer does not suite my needs.

I would like to have a flat, not interpolated 2D graph with z coordinate shown as a color (similar to “col” option in TH2).

TH2 and SetBinContents does not suite my needs, at least with common options I know, for I’d like to see all the points I put into the graph. If I set binning big enough to see all the points, bins are just to small to be well visible. If I decrease the binning, I miss my point of seeing all the points.

With not-interpolated 2D graph I could have some points partially overlaping, but I could choose the marker size to make all the points well visible.

I know how to do this manually with 1D TMultiGraph, but is it possible to do this somehow automatically with TGraph2D or any other class?

You can use any histogram plotting option on TGraph2D. You can plot a TGraph2D with the option COL.

But than it is interpolated and I need non-interpolated. Is it possible?

have you tried the option TRI1 ?

It draws kind of a surface interpolated between points in 3d.

I need something similiar to TH2 with option “col”, but not interpolated. Just only those points which I added to the graph, nothing in beetween, flat view from above.

I think a most simple thing for a 3d graph :slight_smile:

TRI1 is Delaunay’s triangles, is is not interpolation as in an histogram. Any way if you want really do not want to have any interpolation you should use P or P0 options. The data will be shown as markers. You cannot have something like the option COL without interpolation because TGraph2D is not a binned data set. It is based on points.

I understand. So perheps my mail is rather a feature request, not a question.

Instead of 3d view for P or P0 option, I’d like to have a 2d view from above, with a color of the marker proportional to it’s z value. Would it be difficult to implement?

To see from above you just need to change the angles. For “COL” option with markers, we can had that on the list of things to do.

But I understand this would just make the interpolated COL plot from above.

Could you do non-interpolated? I mean just a P view from above with addition, that the color of the marker is proprtional to the z-value and z-color-scale is drawn on the right (like in COLZ).

That is not what I meant. My points are:

  1. to see the points from above just change the viewing angles.
  2. to see them colored I have to implement a new option (not done yet)

OK, now I understand :slight_smile:

Thank you for all the discussion. I hope more people will benefit from such a feature.

Actually this option already exists and is even documented !!!
it is PCOL
do:

g->SetMarkerStyle(20);
g->Draw(“pcol”);

Sorry to not have thought of it earlier… I thought you had read the doc and I do not have all the options in mind…

[quote=“couet”]Actually this option already exists and is even documented !!!
it is PCOL

Sorry to not have thought of it earlier… I thought you had read the doc and I do not have all the options in mind…[/quote]

Thankyou very much. Only changing the view now and it is exactly what I wanted.

I have read documentation for TGraph2D, TH2, TGraph and TH1… Non of it covers the pcol option. I found this option via google only in TGraphPainter sourcefile and root 4.0 developement notes. I haven’t read the sourcefiles, which I guess is not an uncommon thing. Is it anywhere in the common documentation? Shouldn’ tit be included in TGraph2D reference file?

Yes, all the painting option are in TGraphPainter (like the painting options for histograms are in THistPainter). I will add this one in TGraph2d::Draw

Well, perheps I discorvered a bug, or maybe a missing, half-implemented feature ( I would have to dig into the code). Drawing with “pcolz” (not “pcol”) option, which is undocumented and I haven’t see it in the source, draws a palette-z-scale with correct values but… without any colours.

Anyway, thanks again for this information.

Ok, I’ll check.

Ok. I looked at this. The PCOLZ is not documented because it is not implemented. It is not really straight forward because PCOLZ matches also COLZ and after my first easy tests I get the COL plot AND the P plots together … I need some time.