Plot 3D Spectrum with 100k+ points

Hi there,

I have some spectrum data that I want to analyze in a 3D surface plot.
The data has 3 parameters: Time (X), Frequency derived from FFT (Y) and Amplitude (Z) and at least 100k+ data points. There are 3 options that I’ve tried now: TH3, TGraph2D, TH2.

TH3: Drawing is restricted to a single draw option (“A cloud of points is drawn.”) -> doesn’t work in my case

TGraph2D: Only works with less data points, 100k-1000k is too much (histogram instead of graph is necessary, as I don’t want to see every single frequency from 1-1000Hz anyways)

TH2: Works, but I need to fill the TH2F proportional to the Amplitude because I only have 2 parameters in TH2. -> E.g. Amplitude for data point X/Y = 50 -> Fill 50 times with the same X/Y values. Works for my data, but it isn’t satisfying and takes ~15s (for 100k data points). Plot with surf1.

Now I’ve read in this thread (TH1 Weighted Fill. Problem with errors and draw) that a TH1::FillN( double x, int n) option isn’t implemented, so I guess there’s no other way. Maybe using weights could work, but I’m not sure? My code with the TH2 work-around is working fine (few minutes of runtime at max, doesn’t matter that much), but faster is always better :smiley:

Thanks for your help.

The new version accept much more now. (committed yesterday by Lorenzo)

But I guess not for ROOT 5 (I’m compelled to use Windows at my workplace)?

Ah yes … that’s ROOT 6…

So I guess that there’s no other option with Root 5.34 other than with my workaround?
Sorry btw. that I didn’t mention that I use 5.34.

Yes, using a TH2 is the best on your case.


just as a short remark: You can indeed use the weight parameter instead of calling x-times Fill. Alternatively just use SetBinContent(binx,biny,content) method.


Thanks a lot! Indeed, I could have used the weight option from the beginning on.
Would have been easier.
I’m redoing this in my code now :laughing: