gStyle->SetErrorX(0) in TGraphAsymmErrors

According to TGraphPainter.html, gStyle->SetErrorX(0) removes drawing of errors along x.
I can get it to work on histograms, but not on graphs with error bars.
See for instance:

TH1D tots("tots","tots",2,0,2);
TH1D pass("pass","pass",2,0,2);
double* w = 0;
double t[] = {0,0,0,0,1,1,1};
double p[] = {0,0,0,1};
tots.FillN(7,t,w);
pass.FillN(4,p,w);
TGraphAsymmErrors a(&pass,&tots,"cp");
a.SetMarkerStyle(20);
pass.SetMarkerStyle(20);
gStyle->SetErrorX(0);
pass.Draw("em");  // <-- x-errors absent
a.Draw("apz");    // <-- x-errors present

This is valid for TGraph … If you using TGraphAsymErrors Errors it is assume you want to see the errors as you spent time to define them …

Well, it’s common practice to use asymmetric errors only in Y. For instance, you don’t care about X errors when using TGraphAsymmErrors::Divide to get efficiencies with binomial errors from two TH1s.

Could you please consider extending the validity of gStyle->SetErrorX(0) from TGraph to TGraphAsymmErrors in a future release?

In that case make your errors along X equal to 0 when you create the TGraphAsymmError.

I see. To avoid X errors in an efficiency plot from TGraphAsymmErrors::Divide, loop point by point calling SetPointEXlow(i,0) and SetPointEXhigh(i,0). Not elegant, but a solution after all.

I have a use case where I’d like to keep the X error information (I use it to store variable bin widths from which I compute integrals); I would just like not to display it when I make the plot. It would be really neat if gStyle->SetErrorX(0) would do that.

Welcome to the ROOT forum.

gStyle->SetErrorX() acts on histograms, not on gpaphs. It will be quite confunins if it will have an effte on graph also. You need to make a new graph with errors on X equald to 0.

Thanks, that’s what I ended up doing.

I confess I am a relative novice with Root, but I note that it was not really obvious to me from the ROOT reference guide that gStyle->SetErrorX() only works on histograms. Comments to the method immediately above it, SetEndErrorSize(), do say that that method works on both TH1 and TGraphErrors.