Display Float_t type in exponential form in labeling Histograms

Hi,

I am plotting a TH2F with Draw(“colzTEXT”); to fill in the box labelled with cross section, the cross section is Float_t type of order 10^-2 pb. I wonder how to display those float number in exponential form (scientific notation) inside the box?

Thanks.

Siew Yan

Hi Siew,

try setting

before you draw the histogram, here is a small example:

TH2F* h = new TH2F("", "", 10, 0., 10., 10, 0., 10.);
h->Fill(2, 3, 10000);
gStyle->SetPaintTextFormat("e");
h->Draw("colztext");

Hi Yus,

Thanks for the tricks, it work! However, on the other hand is there a possible way in ROOT to display a long float up to 3 sf in the box with exponential form?

Cheers,

Siew Yan

Hi Siew,

sure. 3 SFs means 1 SF before the “.” and 2 after, so here it goes:

TH2F* h = new TH2F("", "", 10, 0., 10., 10, 0., 10.);
h->Fill(2, 3, 10000);
gStyle->SetPaintTextFormat(".2e");
h->Draw("colztext");

=D> =D> =D> =D> Thanks you very much!!!

Cheers,

Siew Yan