TStyle feature?

Hi all,

this is probably a question for developers. I included a macro to illustrate my problem. When I started to work with ROOT I thought it was finally program where it was easy to apply new styles - if one wants to create figures for publication, presentation etc. But lately I discovered:

If I create a TGraphErrors (it is the same with histograms, TMultiGraph…) in a macro and after some manipulation I draw it everything is fine. I mean if I apply a different style everything is changed according to whatever gStyle says. But if I save my objects (in my case TGraphErrors) in a TTree and write it to a file and then open it and read it and simply draw it only some features are changed. In particular in case of TGraphErrors (you can see in enclosed macro if you run it - .x Problem1.C) only global title, lines around and pad margins are changed. The axis labels and titles stay the same way as they were saved.

You can try running macro as it is (with default style) and then do for example:
[root].x Problem1.C

and you will see that graphs in the upper row are changed properly but the ones (they are actually the same graphs) loaded from a root file are not.

So my question is if this is a feature or a problem. My expectation would be to: either save ALL the style features with an object or NONE (which I would prefer). Because then it is much easier change the final figure layout by simply applyig a new style. Then the work with root becomes much easier - one can prepare all their figures (graphs, histograms …) and save it in a ROOT file and later on apply an uniform style.

I am running version 4.00.08f

thank you

PS: Does anybody know why gPad->SetLogy(1); creates error: Zero requested on logarithmic axis…even though if I print g->Print() contents of my graphs there are NO zeros…
problem1.tar.gz (11.9 KB)

We will investigate the problem. Meanwhile I propose the following workaround. Replace
t->Branch(“graph”,“TGraphErrors”, &graph, 32000, 99);
t->Branch(“graph”,“TGraphErrors”, &graph, 32000, 0);


I tried replacing “99” with “0” but I didn’t see any change. Did it work for you?

I don’t know if you understand my point. I thought it was easier for everybody to have actual data and style separated. I mean that all objects contain only data and style can be applied afterwards (or changed by simply changing pointer to gStyle object. Right now it seems like TGraphErrors “remembers” style of axis labels and titles as it was saved in TTree. I don’t know how difficult it is to implement this “separation” of data and styles in ROOT - I am just bringing up my point.

The only way to workaround it I found so far is to create new objects on basis of the ones from the file…which is kind of awkward but possible.



What you request is already in place. See Users Guide page 30 and 162. Look items
ForceStyle and UseCurrentStyle.