DynamicSlice equivalent for a 3-D histogram


I have a 3D histogram, and I would like to display the projection along the Z-axis as my cursor moves over the XY plane.

To creat the XY plane,I had to use the TH3::Project3D(“xy”) to creat a 2D histogram in the XY plane. Then the mouse can move over it without turning the 3D histogram.

I can then add to the 2D histogram a TExec object like DynamicSlices(), or use connect(…) method to display the projection along the Z-axis.

Inside the TExec object, I look for a the TH3 histogram by name, then use TH3::ProjectionZ() to selectively project a column of data along the Z-axis.

This works OK, but the implementation is not “neat”.

Is there some way that the mouse can move over the 3D histogram and be able to pick out the X and Y coordinates, as seen looking into the screen? I think I have to re-implement the DistanceToPrimitive() method to do that, but let me know if there is an easier method to do that. A method similar to rene’s recent implementation (TH2::SetShowProjectionX() for TH2) would be a wonderful addition to TH3.

Thanks in advance.

Let me know if you want to see my non-conforming and unruly codes.


You should add an option to THistPainter::ExecuteEvent calling
a ShowProjectionXY, X, Y, etc and implement the equivalent of THistpainter::ShowProjectionX,Y

If you do the job, let us know.


In the CVS head version, I have introduced the necessary changes to implement what you required. There is a new function
see: root.cern.ch/root/htmldoc//TH3.h … Projection

I have implemented a new function in THistPainter that draws the “xy” projection of a TH3. It works. It would be nice if you could extend it to all the missing cases. See the code at
root.cern.ch/root/htmldoc//src/T … rojection3
Let me know if you plan to do the work.


Hi Rene,

I knew you would beat me to it!! That was a nice weekend’s work! I was still strugling how I could retrieve useful coordinate information from TView. I am just about getting to know better the various coordinate systems and conversion methods.

Anyhow, I think I understand what you have just implemented for TH3 for the “xy” case. I have tried running it and it was working.

You have nicely laid down the ground work for a novice like me to take on the challenge of completing the other cases. I am flattered to be offered the oppportunity. Yes. I will try to complete the other cases using what you have implemented as a guide.

I hope timeout is many days away! If people are waiting on it or you loose patience, then put out the rest of codes tomorrow morning!! (my gut feeling: they have probably been written already).

Are you sure you wrote all those codes in one single swoop in one single weekend, including all the cases in TH3::Project3D(…)???