# How to change x and y value of a 2D histogram

**URL:** <https://root-forum.cern.ch/t/how-to-change-x-and-y-value-of-a-2d-histogram/33068>\
**Category:** ROOT\
**Created:** [March 7, 2019, 4:54pm UTC](https://root-forum.cern.ch/t/how-to-change-x-and-y-value-of-a-2d-histogram/33068 "2019-03-07T16:54:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mallg](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@Mallg](https://root-forum.cern.ch/u/Mallg)\
**Post date:** [March 7, 2019, 4:54pm UTC](https://root-forum.cern.ch/t/how-to-change-x-and-y-value-of-a-2d-histogram/33068/1 "2019-03-07T16:54:12Z")

</div>

Hi,

I have a 2D histogram and I’d like to change the x bin value to x-10 and y value to y-5. Is there a way to do that?

Thanks,

* * *

\_ROOT Version: 6.10.02  
\_Platform: redhat  
\_Compiler: C

* * *

---

<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:** [March 7, 2019, 5:04pm UTC](https://root-forum.cern.ch/t/how-to-change-x-and-y-value-of-a-2d-histogram/33068/2 "2019-03-07T17:04:27Z")

</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:** [March 21, 2019, 5:04pm UTC](https://root-forum.cern.ch/t/how-to-change-x-and-y-value-of-a-2d-histogram/33068/3 "2019-03-21T17:04:30Z")

</div>

Closed on March 21, 2019, 5:04pm UTC

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