3D histogram with SURF option?

Hello rooters,

I am trying to plot 3 variable in 3D histogram. I am reading the x, y and z values from text files, then filling the 3D histogram. I want the output to be similar to the picture attached, but I couldn’t find any drawing option for 3D that will give the same result. Any suggestions?
16 PM

I assume you are referring to a TH3, when you say a 3D histogram? This object actual represent four variables, x, y, z, and a value at the point. I believe you want a TH2, which would accept x, y, and a value of z. THistPainter will then support the SURF1 option for a TH2 as indicated in your figure.
https://root.cern.ch/js/latest/examples.htm#th2_surf1

TGraph2D might be an option also.

Thanks! I have a naive question though. I tried:

h->Fill(x,y,z);

but the output z-axis does not show the real z values. Is it a binning thing?

I believe you want the TH2::SetBinContent formulation:

h->SetBinContent(h->FindBin(x, y), z);

For a TGraph2D:

g->SetPoint(g->GetN(), x, y, z);
1 Like

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