Setting X error to 0 for some histograms and not others

Hello Root experts,
I realise this may have been asked before, but could not find a response.
Is there a way to set some histrograms to having an x error bar of 0 but other to use their default x error bar.
The most common method i have found for setting x error bars to 0 is:

gStyle->SetErrorX(0.0001);

But this is a global command which sets all histograms to having this error. Initially i tried to put this command in just before i draw the histograms were i want this to be true and the reset the Errror for the hists which i want to have an error:

gStyle->SetErrorX(0.5);

However in the final plot (since they are on the same canvas) both histogram seem to just show whatever gStyle setting i did last.

Is there any way to what i want to do or do i need to convert the hists to TGraphErrors or some such roundabout method?

Cheers,
Anthony

Hi Anthony,

you can always convert your histograms in graphs:
root.cern.ch/root/html/TGraphErr … phErrors@7

Cheers,
Danilo

Hi Danilo,
Thanks for your quick response!
Do you suggest i make those hists which i want to have an x errorbar as TGraphErrors and those which i want without x errors as TH1s and then just use the gStyle->SetErrorX which will only affect the hists?

Cheers,
Anthony

Hi Anthony,

I think this is what I understood you wanted to do from your post :slight_smile: It may well be a good option in your case…

Cheers,
Danilo

Hi Danilo,
I am trying to do as you suggest, and i have managed to turn the hists into a TGraphAsymmErrors, but when i set the gStyle it also means that the x errors on the hist and these tgraphs go to 0. Does it matter where when calls gStyle?

Thanks for all your help.
Anthony

When you have turned the 1D histograms into TGraphAssymErrors you have the full control on the the four errors. You do not need the gStyle setting any more.