# Horizontal scaling for histogram

**URL:** <https://root-forum.cern.ch/t/horizontal-scaling-for-histogram/44533>\
**Category:** ROOT\
**Created:** [April 22, 2021, 9:37am UTC](https://root-forum.cern.ch/t/horizontal-scaling-for-histogram/44533 "2021-04-22T09:37:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![T\_man](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/b487fb/32.png) [@T\_man](https://root-forum.cern.ch/u/T_man)\
**Post date:** [April 22, 2021, 9:37am UTC](https://root-forum.cern.ch/t/horizontal-scaling-for-histogram/44533/1 "2021-04-22T09:37:17Z")

</div>

Hello everyone,

I have a histogram in a root file, I want to add a horizontal factor (shift the histogram to the left),  
I tried to do this  
`hist2 = 8 * hist1`  
But I get an error " **invalid operands to binary expression (‘int’ and ‘TH1S \*’)**"  
Is there a way to add in the horizontal factor?

---

<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:** [April 22, 2021, 9:42am UTC](https://root-forum.cern.ch/t/horizontal-scaling-for-histogram/44533/2 "2021-04-22T09:42:25Z")

</div>

A similar question was asked here: [Shift bins under modulus](https://root-forum.cern.ch/t/shift-bins-under-modulus/44477)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 22, 2021, 9:47am UTC](https://root-forum.cern.ch/t/horizontal-scaling-for-histogram/44533/3 "2021-04-22T09:47:20Z")

</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 (…

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 6, 2021, 9:48am UTC](https://root-forum.cern.ch/t/horizontal-scaling-for-histogram/44533/4 "2021-05-06T09:48:06Z")

</div>

Closed on May 6, 2021, 9:48am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
