Home | News | Documentation | Download

Fixing the TGraph2D/TPolyMarker3D drawing

Dear ROOTers,

TGraph2D drawing differs significantly from TH3 drawing. In the TGraph2D, from what I understand, TPolyMarkers3D are used to draw points and they are not real 3D objects. The result is that they always appear in the order of drawing. Therefore it is often quite difficult to asses 3D properties of such a graph - rotation does not show the other side of the graph. The object that is geometrically closer to the viewer is not necessarily the one visible. This is not the case with TH3, where boxes/spheres are real 3d objects and rotating shows a proper side of the histogram, the one closest to the viewer.

As TPolyMarker3D is a dot, could it not be replaced with a sphere used to draw TH3? Or perhaps a different class, that would make a real 3D marker just like the TH3 sphere or box, as I understand that the idea between TPolyMarker3D is to have standard marker styles placed in semi-3D.

I tried to look into how TH3 draws spheres and boxes myself, but it is done using Rgl, which is rather undocumented. But perhaps to experience ROOT developer, making such a new “marker”, which is just a possibility to draw real 3d box or sphere in TH3 environment, would be a short episode of coding? And this could make TGraph2D like plots much more usable…

ROOT Version: 6.18
Platform: Not Provided
Compiler: Not Provided

If you draw the TGraph2D with single dots it is not a problem. But for bigger markers it can be. I would suggest you try to use the option P0 to draw your TGraph2D. Let me know if it helps. If not, post a small macro reproducing you problem and I will have a look.

Unfortunately, p0 or p with bigger marker does not help, as the last markers seem to be always drawn on top. I attach a macro where TGraph2D has two layers of points, one at z=1, one at z=5, which drawn with “pcol” have different colours. Rotating this graph shows that the markers put into the graph last are always drawn last (and thus “on top” or “closer to the viewer”), even when they should appear obstructed by the other layer.

tgraph2d_problem.cxx (423 Bytes)

The markers are not drawn back to front. Like the with the LINE option they are painted in order (like in a TGraph).

Plot produced with “LINE P0”:

I think it is done the way in order to keep it fast (no extra computation to order the points), because when drawn with an other option requiring order (like TRI1) the points are ordered:

Yes, it seems so. So it would be quite easy to add an option to draw them ordered (without TRI, etc.), I guess?

I would think so. That’s what I was thinking about.

Not that simple indeed… triangles vertices does not always match the cloud of points.

That’s why I was thinking that copying the same drawing method that is used fot TH3 and where it works well could be used (unless someone wants the 2D marker shapes).

TH3 are binned data. A drawing technique cannot be imported to TGraph2D.

Yes, but perhaps just the method of drawing a single box or a single sphere as a marker could be?

Nope … this is a global algorithm expecting binned data.
I need to implement a new technique.

I have done something but that’s not fully satisfactory.

I am not sure what is not fully satisfactory, but surely on this picture it looks much better than what we’ve got now. Thanks!

Yes … but when rotating it gives some weird result sometimes.
May be opening a Jira ticket will help to keep that in mind ?