Move axis exponent into the tick labels?

For a histogram or graph with large axis label values (xx.yy x 10^N), is it possible to move the 10^N from the end of the axis into each individual label?

Using the x-axis as an example:

|--------------|--------------|--------------| x 10^3 0 1.5 3.0 4.5

would become

|--------------|--------------|--------------| 0 1.5x10^3 3.0x10^3 4.5x10^3

(This is an odd request, but a journal editor is insisting that I change this in my plots prior to publication.)



That’s not implemented that way. x10 is always drawn at the en of the axis.

Now implemented in 5.34 and trunk

  • New static function to change the position of the "power of 10"
    near the axis. A static function is used instead of data members
    in TAxis in order to keep the TAxis class small. Adding two
    floating point numbers in that class (in fact in TAttAxis) would
    have a none negligible effect on the Root files’ sizes as there is
    at least two axis per histogram and that there is often 1000th
    histograms in a single file.
    So we choose to follow the same mechanism as for the SetMaxDigits
    static method. The new function is: SetExponentOffset.
   TGaxis::SetExponentOffset(-0.01, 0.01, "y"); // X and Y offset for Y axis
   TGaxis::SetExponentOffset(-0.05, 0.01, "x"); // Y and Y offset for X axis

Dear all

I see that it is possible to offset the Exponent for the X and Y axis. Is it possible to have this also for the Z-axis (e.g. for a TH2F drawn with colors)?
Thanks a lot

It is implemented for x and y axis only.

Thanks, that is what I understood as well. So no solution let’s say.
I acknowledge that this is only aesthetics, so no high priority.
in case someone touches code nearby in the future, it would be great
to have it also for the Z-axis.

I will check in TGaxis

Thanks :slight_smile:

May be it is better to fill a Jira report to not forget. I had no time to look at it recently.

I have a similar problem as @Piet, I tried to invoke TGaxis::SetExponentOffset(-0.05, 0.01, "z"); inside my C-macro, but it has no effect on the exponent position.

As you see, in the left plot I cannot manage to see the -18 exponent.

Has this been solved? Thanks!

Do you have a simple macro showing the problem? I do not have one from the last report three years ago.

Here I share the C-macro to reproduce the full plot.

optics_Primakoff_GridPix_XMM_Vacuum.C (115.4 KB)

Actually, if I uncomment the SetRightMargin on line 24 (which was missing in the original macro) , I am able to observe the exponent, so the problem is solved in that sense. But I was not able to move the exponent in the same way as I was able to move the labels using palette->SetLabelOffset.

So, I guess there should be a way to move the exponent?

SetExponentOffset only works for the x and/or y axes, not for z.
So, indeed, you have to change the margins of the pad/canvas and/or change the size/position of the palette in order to give it enough space to see all (not only the exponent, but any values on the scale could be cut out if there is not enough space).