How to find ex and ey in for error bar

HI !
I am plotting graphs with error bars. I am following examples from internet. But I can not understand how to get the ex value and ey value to have the bars. I have given some of my codes here . Thanks

first off, you use ex and ey in the constructor, but you never define these two:

Then you have to set errors manually for every single point you have, like e.g.
g2->SetPointError(i, ex[i], ey[i]);

ooo, Thanks.
But I defined ex and ey like this;
double ex[4] = {0.0,0.0,0.0,0.0};
double ey[4] = {1, 0.5, 1, 0.5}; But clearly the bars are wrong.

Try: g2->Draw("AP"); // "AP" or "APZ"

but nope…the line is vanished.

What do you mean by “the error bars are wrong”? They seem perfectly fine to me…

I mean I just gave the values like double ey[4] = {1, 0.5, 1, 0.5}; .
I think I should get the errors somehow. Not like i put some values randomly.

:frowning: Nope. The line get vanished.

Yes, it is YOUR responsibility to calculate / set proper errors.

After creating histograms (and before filling them) add:


For your graph, you could then use something like:

x  = histo->GetMean();
ex = histo->GetMeanError();
y  = histo->GetStdDev();
ey = histo->GetStdDevError();