# Numbers in scientific format on the x-axis of 1D histogram

**URL:** <https://root-forum.cern.ch/t/numbers-in-scientific-format-on-the-x-axis-of-1d-histogram/49365>\
**Category:** Newbie\
**Created:** [March 26, 2022, 5:49am UTC](https://root-forum.cern.ch/t/numbers-in-scientific-format-on-the-x-axis-of-1d-histogram/49365 "2022-03-26T05:49:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Songshaptak\_De](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/songshaptak_de/32/27468_2.png) [@Songshaptak\_De](https://root-forum.cern.ch/u/Songshaptak_De)\
**Post date:** [March 26, 2022, 5:49am UTC](https://root-forum.cern.ch/t/numbers-in-scientific-format-on-the-x-axis-of-1d-histogram/49365/1 "2022-03-26T05:49:54Z")

</div>

I want to make the numbers appearing the x-axis of my 1D histogram to appear in a scientific format, i.e. 0.0006 will look like 6x10^-4. I am using ROOT Version: 5.34/09. Is there any function in this version of this ROOT which will help me to display the numbers in x-axis in scientific format ?

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [March 27, 2022, 3:39pm UTC](https://root-forum.cern.ch/t/numbers-in-scientific-format-on-the-x-axis-of-1d-histogram/49365/2 "2022-03-27T15:39:38Z")

</div>

Hi,  
try to use [SetMaxDigits](https://root.cern.ch/doc/master/classTGaxis.html#a6b93d66237560f7b11701402a1a446ce), like this.

```auto
hist->GetXaxis()->SetMaxDigits(1);

```

Should work also in the ROOT old version.

Best,  
Stefano

---

<div class="post-metadata">

**Author:** ![Songshaptak\_De](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/songshaptak_de/32/27468_2.png) [@Songshaptak\_De](https://root-forum.cern.ch/u/Songshaptak_De)\
**Post date:** [March 28, 2022, 5:18am UTC](https://root-forum.cern.ch/t/numbers-in-scientific-format-on-the-x-axis-of-1d-histogram/49365/3 "2022-03-28T05:18:34Z")

</div>

Getting an error like this,  
**AttributeError: ‘TAxis’ object has no attribute 'SetMaxDigits’**

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [March 28, 2022, 6:08am UTC](https://root-forum.cern.ch/t/numbers-in-scientific-format-on-the-x-axis-of-1d-histogram/49365/4 "2022-03-28T06:08:23Z")

</div>

Try just

```auto
TGaxis::SetMaxDigits(1);

```

before drawing `hist`. Just note that this, as the Documentation says, changes the max number of digits in all axes.

---

<div class="post-metadata">

**Author:** ![Songshaptak\_De](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/songshaptak_de/32/27468_2.png) [@Songshaptak\_De](https://root-forum.cern.ch/u/Songshaptak_De)\
**Post date:** [March 28, 2022, 6:27am UTC](https://root-forum.cern.ch/t/numbers-in-scientific-format-on-the-x-axis-of-1d-histogram/49365/5 "2022-03-28T06:27:14Z")

</div>

Shouldn’t that set the precision for both the axes ?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 28, 2022, 6:31am UTC](https://root-forum.cern.ch/t/numbers-in-scientific-format-on-the-x-axis-of-1d-histogram/49365/6 "2022-03-28T06:31:26Z")

</div>

With the version you are using `SetMaxDigits` was a global setting only (for all axis). The possibility to set it “per axis” appeared later.
