TGraph/TMultiGraph yaxis Ndivisions and range

Hi,

I am finding that JSROOT ignores the y-axis Ndivisions and SetRangeUser when it loads and displays graphs stored in a root file. Is there a way for me to change that? (I can set the range again in JSROOT using object.fHistogram.fMaximum & fMinimum).

Edit: Next, I found that I can also set the Ndivisions in JSROOT using object.fHistogram.fYaxis.fNdivisions. :slightly_smiling_face:

Thanks for your help.
Naomi.

Hi Naomi,

Thanks for your question. Let me add @linev in the loop.

Dev

Hi Naomi,

Can you provide reproducer of the problem - as ROOT macro or in ROOT file?

Regards,
Sergey

The problem was that the y-axis user range (and Ndivisions) stored in the graph in the .root file were ignored when JSROOT drew the graph on my website, it used its defaults. After I wrote my question, I found how to set these again in JSROOT, so I have a workaround. :slight_smile:

I’ll attach one graph that showed this problem when viewed online, its values are all 1 but its possible values are -1,0,1, so I wanted to set the y-axis to show all three as it’s then easier to compare with earlier versions.

Naomi.

singlegraph.root (6.2 KB)

In your file histogram associated with TGraph has fMinimum/fMaximum values set.
They are -1.4 and 1.4 respectively. So these values overrule all other Y axis settings.

And if plot same TGraph with plain ROOT - I see very similar result.
Including configured divisions numbers

When I use JSROOT to show the graph loaded from the file, those configured settings are lost.

Here link how your file shown with latest JSROOT release.

Is it that you see?

Yes!

Sorry. I had confused it with a TMultiGraph that I built in JSROOT. The graphs (as in my example file) do load perfectly, but I had combined several into a multigraph which used default axis values until I worked out how to set them properly for myself. So my original complaint was wrong and everything is fine. :slight_smile:

It did take me a while to find out how to set the axis settings, so maybe that info will help someone else.

One must be careful when building TMultiGraph object.
In JSROOT set gr.fHistogram = null for all used graphs or gr->SetHistogram(nullptr); in the ROOT. Otherwise graph settings may conflict with settings in TMultiGraph.

1 Like