Th3 class

Hello,

I want to make a 3D graphique but when I use the TH3 class, the points are not well placed. If someone knows a better class or can help me for problem.

thanks

Can you provide a small example showing what you mean by “the points are not well placed” ?

if i want (x,y,z) (10,10,10) they might be placed at (9,15,10) ???
I don’t understand how works the TH3 class.

Can you , if you know, put me a short example like f(x,y,z)=x+y+2*z ?

thanks

TH3 is an histogram so it is binned. So the drawing is done bin wise …
How did you create TH3 ?
Also, what kind drawing you are doing ? Are you using the BOX option ?
Again it would be easier if you send a small script showing what you are doing …

example:

void tf3(){
   TF3 *tf3 = new TF3("sample", "x*x+y*y-z*z-1", -2., 2., -2., 2., -2., 2.);
   tf3->Draw();
}

I want to do something like this

[code]void tf3()
{
TFile* f = TFile::Open(Tree);
TTree* t;
f->GetObject(“test”,t);
TF3 *tf3 = new TF3();

while ( i <t_>GetEntries())) 
{
	t->GetEntry(i);
	tf3->Fill(x,y,z);  //Where x,y,z are in the tree
}

tf3->Draw();
}[/code]

If you have a TTree why don’t you simply do:

t->Draw("x:y:z");

cause this draw me all points . I need to plot only few points corresponding on my needs. I can also use TPolyMarker3D but i can’t see the axis …

Any ideas ?

Impose a selection to draw only the points you need. See:
root.cern.ch/root/htmldoc/TTree.html#TTree:Draw

Example:

t->Draw("x:y:z","x>0 && y<0");

Or set the number of entries you want to see (“entries” parameter in TTree::Draw)

thanks i try but my condition are very hard so …

so change the number of entries …

???

My tree is very big (more than 50000 entries) so the Draw fonction is to long.
With TPolyMarker3D I can select only the points i want to plot with a fast reading of the tree, then plot only the few points i want . I very need to see the axis and TPolyMarker3D->Draw() shows only the points

idea?

I apologize this work very well ! but i got one more problem … I want to plot points in separate colors and i don’t see how to do it with this tool.

I try to plot two on the same canvas but the seccond erase the first on

I try things like this but that won’t works

t->Draw("xpos:ypos:zpos: zpos<0?1:3");

Do a first plot using one color, and plot a 2nd one using option “SAME” with an other color.

Great thanks , i was looking for the options …

Great thanks !

I was looking for the options … you were faster