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

From: Olivier Couet <couet_at_mail.cern.ch>
Date: Tue, 18 Jan 2005 18:26:12 +0100 (CET)


Hi,

 The underlaying algorithm (Delaunay triangulation) in TGraph2d is not meant to be used on regular grid data sets (see http://couet.home.cern.ch/couet/root/ht13.html). If your data are on a regular grid you better use a TH2.
And yes, it is slow when the number of points reach a few hundreds (but there is a lot to do !). Also when you increase the number of bins in the histogram the interpolation can be very long. In TGraph2D the Delaunay triangulation is very useful on random data set. You can still plot your TGraph2D with the "P" or "P0" options which do not trigger the Delaunay algorithm. Also, Have you tried the "TRI1" option (that's an other option, see the help) ?
 May be the speed can be increased in the future. I already tried to optimize this code as much as I can. Oh yes, you can also reduce the number of iterations (see help again).

Cheers, Olivier

On Tue, 18 Jan 2005, Brett Viren wrote:

> Hi,
>
> 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:
>
> http://minos.phy.bnl.gov/~bviren/big-TGraph2D-problem.tgz
>
> 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.
>
> Thanks,
> -Brett.
>
>

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Tue Jan 18 2005 - 18:30:13 MET

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