Ploting a TGraph2D takes a long time

Hi ROOTers
I am trying to plot a simple example (see below) of a 2Dgraph. Does this take long to plot anyone? This is a 250 by 250 array. However I notice my program is taking forever to generate the plot. Is this normal?

TCanvas *c1 = new TCanvas(“c1”,“Graph2D example”,0,0,600,400);
TGraph2D gr2D = new TGraph2D(250250);
int k=0;

for (Int_t i=0; i<250; i++) {
for (Int_t j=0; j<250; j++) {
printf(“Point set: %.2d %.2f %.2f %.2f\n”,k,i,j,(double)i+j);

return c1;

Testing my code, I notice that when I use draw(“col”) it was taking forever to handle 250250 points. However when I change my drawing options to “pcol” I have no problem (neither time lag) plotting a 250250 data set.


When you plot TGraph2D with the option TRI COL SUR LEGO etc … the Delaunay triangulation is done. This is an heavy process which takes time if you have a lot of points. When you plot the TGraph2D using the PCOL, P or P0 options the triangulation is not done, the points are plot directly.
TGraph2D is meant for 2D data set on irregular grids. If your data are on a regular grid (like in your example) you better use a 2D histogram.

Sorry could you define what is a data set in an irregular grid? It is not clear what is the difference between a TGraph2d and a hist2d.
Thxs for the comment. BTW is there a limitation on how many pts one could used in a 2D grid? Let’s say I have a 4096x4096 binned data set to plot. Hist2D would perform better than TGraph2D?

yes … for a such large data set you should use TH2 … and as you said it is binned data it is for sure a TH2… note that that will be a huge histogram… the bins will be much smaller than a pixel …