# Plotting Y error bars only on a TGraphErrors

Hi,

I have a TGraphAsymmErrors and I only want to draw the Y error bars, I was hoping this would be something simple in the draw command like:

gr->Draw(“APEY”);

But this still draws both X and Y errors.

Can you help?

Thanks, Claire

Define the X errors equal to zero.

This is what I would have done had I been creating the graph using arrays myself. However, I get the graph from a the bayes divide of 2 histograms. To set the X errors to 0.0 I have to access the information in the graph, reset the errors and re plot (I imagine).

Surely there is/should be an option to draw either or both error bars?

Claire

There is no option doing that see:
root.cern.ch/root/html/TGraphAsy … rors:Paint
It was assumed that if one uses a TGraphAsymmErrors object it means he wants really to define 4 differents errors and therefore wants to plot them.

Ok, thanks.

I realise it’s rare that one would want to do this but if it’s easy to code it as an option in the draw method I think it would be useful.

Claire

That’s really simple to do if you need it. That is a 4 lines little procedure like in the following example:

``````void asymsetEXto0()
{
double x[] = {0, 1, 2, 3, 4};
double y[] = {0, 2, 4, 1, 3};
double exl[] = {0.1, 0.2, 0.3, 0.4, 0.5};
double exh[] = {0.5, 0.4, 0.3, 0.2, 0.1};
double eyl[] = {1, 0.5, 1, 0.5, 1};
double eyh[] = {0.5, 1, 0.5, 1, 0.5};

TCanvas* canvas = new TCanvas("test", "");
TGraphAsymmErrors* gae = new TGraphAsymmErrors(5, x, y, exl, exh, eyl, eyh);
gae->SetFillColor(2);
gae->SetFillStyle(3001);

SetEx(gae,0.);

gae->Draw("a2");
gae->Draw("p");
}

void SetEx(TGraphAsymmErrors* gae, Double_t Ex)
{
Int_t np = gae->GetN();
for (Int_t i=0; i<np; i++) {
gae->SetPointEXhigh(i,Ex);
gae->SetPointEXlow(i,Ex);
}
}``````