# Copying a histogram from the tree in a root file and changing the range

**URL:** <https://root-forum.cern.ch/t/copying-a-histogram-from-the-tree-in-a-root-file-and-changing-the-range/28122>\
**Category:** ROOT\
**Created:** [February 28, 2018, 8:54pm UTC](https://root-forum.cern.ch/t/copying-a-histogram-from-the-tree-in-a-root-file-and-changing-the-range/28122 "2018-02-28T20:54:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hansoullee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hansoullee](https://root-forum.cern.ch/u/hansoullee)\
**Post date:** [February 28, 2018, 8:54pm UTC](https://root-forum.cern.ch/t/copying-a-histogram-from-the-tree-in-a-root-file-and-changing-the-range/28122/1 "2018-02-28T20:54:20Z")

</div>

hello  
I know this should be a simple problem but for some reason I’m running into issues.  
I tried so many methods mimicking the examples, I dont even know what stage I’m in anymore.  
The issue is simple. I would like to read the root file, copy the histogram stored in the tree, and change the axis of the histogram.  
How could this be achieved?  
Please let me know  
Thank you

---

<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:** [February 28, 2018, 9:28pm UTC](https://root-forum.cern.ch/t/copying-a-histogram-from-the-tree-in-a-root-file-and-changing-the-range/28122/2 "2018-02-28T21:28:55Z")

</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 14, 2018, 9:29pm UTC](https://root-forum.cern.ch/t/copying-a-histogram-from-the-tree-in-a-root-file-and-changing-the-range/28122/3 "2018-03-14T21:29:15Z")

</div>

Closed on March 14, 2018, 9:29pm UTC

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