TTree plot with error bars

If i have

Double_t x[n],
Double_t y[n] and
Double_t dy[n],

where dy[i] is the error of y[i], loaded into a TTree (“x:y:dy”), is it possible to get a plot of y vs. x with error bars.
The closest I came was doing

tree->Draw(“y : x>>hp”,"",“profs”), which sort of works

(although there seem to be some binning issues, since the x values look slightly shifted from the original position), but I’m not sure how to get the error bars on there. Thanks in advance.

It is not totally clear what you want to do. Just in case you simply want to draw a graph of N points x[i],y[i] with error bar in y = dy[i] and your data in a Tree,
you can do:

tree.Draw("x:y:dy","","goff"); TGraphErrors g(tree.GetEntries(),tree.GetV1(),tree.GetV2(),0,tree.GetV3()); g.Draw("ap");

Thanks for the reply. What I meant was pretty much if it’s possible to do the same straight from the TTree::Draw() [or Fit] function, without having to use TGraphErrors. But this works for me.