I want to make a plot like this
three “layers” of histograms from one TH3 with a line going across them.
But what I get from this code (1.6 KB) is this plot
As seen (it’s better if you run it yourselves), the line is at the back of the entire histogram, and if I draw it after the TH3, it’s completely in the front. I can’t seem to get the desired effect of going through each “layer”.
I’d appreciate your help with this problem, thanks in advance to you all.
ROOT Version: 6.14/04
You macro doesn’t run:
In file included from input_line_11:1:
/Users/couet/Downloads/Many3DHistograms.cc:40:5: error: use of undeclared identifier 'ZOffset3D'
/Users/couet/Downloads/Many3DHistograms.cc:62:5: error: use of undeclared identifier 'NewPalette'
NewPalette(T, 100,19,12); //greys, works great
/Users/couet/Downloads/Many3DHistograms.cc:73:1: error: C++ requires a type specifier for all declarations
@couet and what would be the right type for this -
TGraph2D as suggested by @juliangb or would you use e.g.
We have a similar example here.
I will try to fix this macro and see what’s can be done.
In “this code” the two functions ZOffset3D and NewPalette are missing. Can you post a version containing them ?
I’m sorry, here it is with all the functions
Many3DHistograms.cc (2.6 KB)
I can run your macro now. I see you are using a TGraph2D to draw the line. I would suggest you look at https://root.cern/doc/master/annotation3d_8C.html and draw the line
as done in that example using TPolyLine3D
I did use PolyLine3D as you indicated before, but ended up with the same result:
Updated code: Many3DHistograms.cc (2.5 KB)
I found this topic interesting so I gave it a try:
if the line is drawn first, it will be behind any element of it.
if the TH3D is drawn first, the line always float in front of the histogram.
It seems like the visualization didn’t seem to handle the relation between objects?
Yes, that’s exactly my problem. I don’t know if there’s an object that can draw a curve, interacting with (in this case) a TH3 object.
You can draw the line after like in the attached version of you macro but that does not really help as the line and the TH3s do not known each other and there fore there is not proper hidden line removal done.
Many3DHistograms.cc (2.4 KB)
Exactly, in my macro I drew it before the histogram, but as I said before
Isn’t there an object that can draw a curve that goes through another? Or a way to make it look like it? I looked everywhere and couldn’t find an answer.
May be TGeo machinery . What you are doing looks like a detector with tracks.
Yes, that’s exactly what I want to reproduce. Thanks for the advice, I’ll check it.
I could find a way to make it look better, although it still has an error.
This is the new code: Many3DHistograms.cc (4.2 KB) (sorry it’s quite inelegant, couldn’t think of a better way of doing it).
This is the plot if you see it from above:
It’s the same if you rotate it around the z-axis, it seems to accomplish the desired effect.
But if you want to see it from below, it looks like this:
So it still needs some adjustments.
While I’m at it, how can I draw the palette bar at the right from a given value, let’s say 100?
the minimum of the palette is the minimum of the histogram drawn with option colz.
how about going to “real 3d”
Many3DHistograms_OS.cc (4.0 KB)
In this you probably wouldnt need the TH3
I need the minimum of the histogram to be 0, but I don’t want to show values between 0 and 100 in the palette bar, I don’t know if there is a way of changing it without modifying the histogram.
This seems really good, but when I try to run it it gives me the error
error: invalid use of incomplete type ‘class TGLViewer’ glv->DoDraw();
your ROOT installation seems n o t to contain OpenGL
to find out type:
and look for