Best way to draw large 2D scalar field (TGraph2D is too slow).

From: Brett Viren <>
Date: Tue, 18 Jan 2005 11:53:30 -0500


I want to plot a 2D scalar field (nu osc probabilities as a function of 2 parameters) defined on a rectangular x,y grid with many (100x100, preferably more) grid points. I've tried to use a TGraph2D to hold the data by calling SetPoint() once for each grid point then using SetNp{x,y}(100) to size the underlying TH2 such that it has a number of bins matching exactly the number of grid points. However, a subsequent Draw("colz") takes a very long time to complete, (many minutes on an Opteron 248).

Can someone recomend a better way to display this data?

To reproduce get:

shell> tar -xzvf big-TGraph2D-problem.tgz shell> root -l

root [0] .L data2tgraph.C
root [1] TGraph2D numu[3]
root [2] data2tgraph("prob/numu/output",numu)
root [3] numu[1].Draw()

<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [4] numu[1].SetNpy(100)
root [5] numu[1].SetNpx(100)
root [6] numu[1].Draw("colz")

(...wait and wait and wait...)

The first draw was relatively "fast" (a couple of minutes). The second is still going after tens of minutes. Since it only takes a few seconds to read in all of the data to memory, I don't think plotting it should take so long, should it?

Is there a better way?

Specs: ROOT 4.01/03 18 November 2004, Debian x84 (32bit), GCC 3.3.5, Opteron 248.

-Brett. Received on Tue Jan 18 2005 - 17:53:46 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:04 MET