# How to change the scale of the x axis?

**URL:** <https://root-forum.cern.ch/t/how-to-change-the-scale-of-the-x-axis/22204>\
**Category:** ROOT\
**Created:** [November 14, 2016, 4:07pm UTC](https://root-forum.cern.ch/t/how-to-change-the-scale-of-the-x-axis/22204 "2016-11-14T16:07:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hobbybastler](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/4af34b/32.png) [@Hobbybastler](https://root-forum.cern.ch/u/Hobbybastler)\
**Post date:** [November 14, 2016, 4:07pm UTC](https://root-forum.cern.ch/t/how-to-change-the-scale-of-the-x-axis/22204/1 "2016-11-14T16:07:56Z")

</div>

I have a histogram like this:

```auto
	TH1F* h = new TH1F("asd","asd",100,0,1000);
```

how can I change the scale on the x axis?

I want to do something like this…

```auto
	h->ChangeXScale(1000);
```

and now h should be the same as

```auto
	TH1F* h = new TH1F("asd","asd",100,0,1);
```

For example: Lets say the original histogram has on the xaxis energies from 0…1000keV, how can I change the histogram to have on the xaxis 0…1MeV (with same number of bins, actually not changing the underlying data at all)

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [November 14, 2016, 4:09pm UTC](https://root-forum.cern.ch/t/how-to-change-the-scale-of-the-x-axis/22204/2 "2016-11-14T16:09:32Z")

</div>

> [@Can we shift histogram for several channels?](https://root-forum.cern.ch/t/can-we-shift-histogram-for-several-channels/12050/2):
>
> I’m not sure if this is fully kosher, but suit yourself : #include "TAxis.h" #include "TH1.h" #include "TArrayD.h" Double\_t ScaleX(Double\_t x) { Double\_t v; v = 10 \* x + 100; // "linear scaling" function example return v; } Double\_t ScaleY(Double\_t y) { Double\_t v; v = 20 \* y + 200; // "linear scaling" function example return v; } Double\_t ScaleZ(Double\_t z) { Double\_t v; v = 30 \* z + 300; // "linear scaling" function example return v; } void ScaleAxis(TAxis \*a, Double\_t (…
