Drawing data from ntuple

hello every one ,
i have data in ntuple and i want to draw them in the same graph.
i wrote in the macro :
ntuple->Draw(“a:x”);
it works but i want to draw also b:x , c:x , d:x …
i tried
ntuple->Draw(“b:x”,“same”);
but it doesn’t work !!

any help please ?

ntuple->Draw(“b:x”, “”, “same”);
see: http://root.cern.ch/root/html/TTree.html#TTree:Draw@2

thank you so much ,

i want to ask about how can i change the maximum value of the y axis here in my case ?

Draw the variable that gives the widest y-axis range as the first. Then draw the rest using the “same” option.

Another option is to loop over all variables, get the maximum and minimum, and drawing a blank TH2F first with the right range and then drawing everything on top. This might be easier programmatically than trying to figure out which pair to draw first.

Cheers,
Charles

You could also try (but then the minimal value of the y-axis may be too high):
ntuple->Draw(“max(max(max(a, b), c), d):x”, “”, “axis”);
ntuple->Draw(“a:x”, “”, “same”);
ntuple->Draw(“b:x”, “”, “same”);
ntuple->Draw(“c:x”, “”, “same”);
ntuple->Draw(“d:x”, “”, “same”);

[quote=“Pepe Le Pew”]You could also try (but then the minimal value of the y-axis may be too high):
ntuple->Draw(“max(max(max(a, b), c), d):x”, “”, “axis”);
ntuple->Draw(“a:x”, “”, “same”);
ntuple->Draw(“b:x”, “”, “same”);
ntuple->Draw(“c:x”, “”, “same”);
ntuple->Draw(“d:x”, “”, “same”);[/quote]

I think it’s pretty clear that this doesn’t scale well. (Go ahead and write it up for 20 variables :slight_smile: ).

thaaank you , it works :smiley: