# Shift a histogram along the x-axis

**URL:** <https://root-forum.cern.ch/t/shift-a-histogram-along-the-x-axis/41017>\
**Category:** Newbie\
**Tags:** root\
**Created:** [August 17, 2020, 1:11pm UTC](https://root-forum.cern.ch/t/shift-a-histogram-along-the-x-axis/41017 "2020-08-17T13:11:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newbie](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Newbie](https://root-forum.cern.ch/u/Newbie)\
**Post date:** [August 17, 2020, 1:11pm UTC](https://root-forum.cern.ch/t/shift-a-histogram-along-the-x-axis/41017/1 "2020-08-17T13:11:26Z")

</div>

Dear, is there a simple way to shift a TH1 along the x-axis with a fixed constant?

i.e. every bin of the histogram moves with a constant value C\_x to the left or right depending on the sign of the constant

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [August 17, 2020, 7:06pm UTC](https://root-forum.cern.ch/t/shift-a-histogram-along-the-x-axis/41017/2 "2020-08-17T19:06:54Z")

</div>

Hi,

check this out:

> [@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 (…
