# Create TH1 with TAxis

**URL:** <https://root-forum.cern.ch/t/create-th1-with-taxis/52864>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [December 22, 2022, 9:05am UTC](https://root-forum.cern.ch/t/create-th1-with-taxis/52864 "2022-12-22T09:05:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emil\_R](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/emil_r/32/31255_2.png) [@Emil\_R](https://root-forum.cern.ch/u/Emil_R)\
**Post date:** [December 22, 2022, 9:05am UTC](https://root-forum.cern.ch/t/create-th1-with-taxis/52864/1 "2022-12-22T09:05:21Z")

</div>

Dear Experts,  
I have a TAxis Object I obtained from another histogram

> TAxis \*Ax = Hist-\>GetYaxis();

Now I want to create a new histogram with this Axis. Therefor I did the following:

> TAxis \* X = new TAxis(1000,0,2000);  
> TH2 \* NewHist = new TH2(“ThisHist”,“MyHisto”,X,Ax);

This does not work and I have not found a way to make a new Histogram using a TAxis. Can anyone help?  
Thanks,  
Emil

Edit: I already have it running by creating an array of bins from the TAxis, but it would still be interesting for the future, if it is possible to directely use the TAxis.

---

<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:** [December 23, 2022, 4:54pm UTC](https://root-forum.cern.ch/t/create-th1-with-taxis/52864/2 "2022-12-23T16:54:59Z")

</div>

Hi,

> [@Emil\_R](#):
>
> ```c++
> TAxis * X = new TAxis(1000,0,2000);
> TH2 * NewHist = new TH2("ThisHist","MyHisto",X,Ax);
> 
> ```

there is no such constructor mentioned in [ROOT: TH2 Class Reference](https://root.cern.ch/doc/master/classTH2.html#pro-methods)

---

<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:** [January 5, 2023, 10:09am UTC](https://root-forum.cern.ch/t/create-th1-with-taxis/52864/3 "2023-01-05T10:09:51Z")

</div>

```auto
auto X = new TAxis(1000,0,2000);
auto NewHist = new TH1D(“ThisHist”,“MyHisto”,X->GetBsins(),X->GetXmin(),X->GetXmax());

```
