Forcing exponential notation on an axis

Is there a way to force exponential notation on an axis? I am plotting a TH2F, and the vertical axis goes from 29000 to 36000. ROOT seems to want to write those values, instead of 2.9 and 3.6 with a 10^4 at the top.

Use:

TGaxis::SetMaxDigits(n);

where “n” is the maximum number of digits

Ah, okay, thanks. That does work. Second question: I see how I can create my own TGaxis, and then draw a histogram in it, but is there a way to access the TGaxis object that is created when I invoke the TH1F::Draw() command? From the TAxis Class Description:

“To make a graphical representation of an histogram axis, this class references the TGaxis class.”

I was hoping I could do something like

TH1F *h1 = new TH1F(“h1”,“h1”,100,-10,10);
h1->FillRandom(“gaus”,100000);
h1->Draw();
h1->GetXaxis()->GetGaxis… <- how can I get the TGaxis object?

or, is the only way to make your own TGaxis?

thanks!

jesse

From TH1 you can get TAxis but not TGaxis. And TAxis doesn’t have a TGaxis member. But why do you need access to TGaxis ? TAxis is enough I think.

Oh, I want to access the

SetMaxDigits(n)

feature for my axes which are made when I draw a histogram to tune down the number of digits, which seems to only exist for TGaxis.

Jesse

There is only value for all axis. It is a global variable. In TGaxis.cxx we have:

Int_t TGaxis::fgMaxDigits = 5;

So there is not need to access it, as it is 5 or a new value you set.

1 Like

Ohhh, I’m so sorry – I just didn’t understand on the first pass. I got it now. My brain wasn’t comprehending the fact that it’s a global variable, even though you said it.

Thanks!

Jesse :smiley: