Issue related to Contour Plots with TGraph2D

ROOT Version: ROOT 6.24/06
Platform: Ubuntu 20.04.4 LTS
Compiler: g++ 9.4.0

I trying to make a contour plot with following macro:

void Contour(const char *inputFile){
  TGraph2D *g_temp = new TGraph2D(inputFile); //,"%lg %lg %*s %lg"

I have attached the sample data file too. What I am getting is a blank canvas. Isn’t it the way to do this?
Will appreciate any help.
contour.txt (2.1 KB)


@couet Looks like a problem in ROOT 6 (maybe the Delaunay is misbehaving and sets improper y-axis and z-axis limits).

@Saumyenk Try to use ROOT 5 and the "COLZ" drawing option.

But, as I remember, I have used this code earlier also in ROOT6 (v6.14/04, g++v5.4.0) to plot this kind of graph. This time I don’t why it’s happening.
Anyway, I’ll try to do this ROOT5 and let you know.

Thank you so much @Wile_E_Coyote for the comment.


The problem is related to your data. Delaunay triangulation hates data points that are placed on a regular rectangular grid (at least in ROOT).

Okay. Yes, I tried with Mathematica too. There also a blank graph, I am getting. So, yes the data.
Thanks a lot @Wile_E_Coyote .


Using the plotting option "p0"we can tell the points are in the same plane.

@couet The drawn frame uses an “improper” histogram (the proper y-axis would be between 1e-10 and 1e-6).

Yes the Y limits are not the best we can expect. I am looking at it.

I found the problem but need to find the proper fix.

@couet Try also if it draws well with “log y” (looking at the “raw data”, it’s probably more important than “linear y”).

@couet, is this plot coming with TGraph2D itself, or some other class?


From TGraph2D but with some temporary code change. I do not have the proper fix yet. I also tried to find a workaround with the current code but I didn’t un til now. I will work on that today.

1 Like

Fix here: Improve TGraph2D limits computation by couet · Pull Request #10677 · root-project/root · GitHub

The PR is merged now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.