TGaxis::ChangeLabel on secondary ticks


ROOT Version: /cvmfs/sft.cern.ch/lcg/releases/ROOT/6.14.00-bc766/x86_64-slc6-gcc62-opt
Platform: Not Provided
Compiler: Not Provided


Hi experts,

Following the example to make pi axis in the TGaxis case, I would like to customize the labels on the secondary labels instead of primary. I tried giving 100 + n as the label number but this did not work.

What should I give instead to make it work? As a pre-emptive response to “use primary tick instead”, I need the secondary ticks because the primary one is already used for defining the grid. This is for the “unrolled plot” like in [1]. But unlike this plot I don’t want to change the bin label and prefer to work with ticks instead so I can introduce tertiary ticks to have a nice range.

Btw: a minor bug report which may not be a bug: if one wants empty labels then giving an empty string doesn’t work, but a string with space does.

EDIT: “Bug” report 2: “axis” draw option prints out just the axes and labels, while “axig” just the axes and grid. An option that draws the both but not the data would be nice. Circumventable with “axis” and then “axig same” but this isn’t so nice.

Cheers,
Afiq

[1] http://cms-results.web.cern.ch/cms-results/public-results/publications/HIG-16-043/CMS-HIG-16-043_Figure_006.png

Labels are on primary ticks only. ChangeLabel allows to modify existing
axis labels not to had new labels.

Yes that’s the way to do it… a white space … empty string is the default which means do not change the text label

do you have a small example ?

Will post a MWE soon.

About the secondary tick labeling, one idea would be to superpose axis with as many primary ticks which are of exactly the same size as the secondary ticks of the histogram axis. Then it’s just an issue of changing the latter axis.

I’m gonna need a guide on how to grab the position of the original axis for this though. Tuning the tick size is probably something about Get and SetTickLength shenanigans, but so far I only saw how to do so for the primary tick.

MWE here. As you can see the if the histo is drawn with axis alone (lines 192, 215), then the grid doesn’t show up while if axig alone then titles don’t show up.

mwe.cxx (6.1 KB)

Yes that’s what the description of the option say. But if you want an empty frame with grid just do:

root [0] auto c = new TCanvas()
root [1] c->SetGridx(1); c->SetGridy(1);
root [2] c->DrawFrame(10.,0.,70.,15.);

No, I want a frame that has axes with their titles and grids but no data.

But fine as I said this is circumventable with “axis” followed by “axig same”. What about the main part: superposing an axis whose primary ticks are the same size as the secondary tick of another?

{
   auto c = new TCanvas();
   c->SetGridx(1); c->SetGridy(1);
   auto frame = c->DrawFrame(10.,0.,70.,15.);
   frame->SetTitle("a;b;c")
}

Ok, I think I’m seeing it better now. I should be able to put something together from that hint.

Considering the issue solved. Thanks for the assistance.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.