# Putting an integer variable in the x-axis label of a 1D histogram

**URL:** <https://root-forum.cern.ch/t/putting-an-integer-variable-in-the-x-axis-label-of-a-1d-histogram/40705>\
**Category:** Newbie\
**Created:** [July 29, 2020, 1:25am UTC](https://root-forum.cern.ch/t/putting-an-integer-variable-in-the-x-axis-label-of-a-1d-histogram/40705 "2020-07-29T01:25:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hep\_1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hep_1/32/21930_2.png) [@hep\_1](https://root-forum.cern.ch/u/hep_1)\
**Post date:** [July 29, 2020, 1:25am UTC](https://root-forum.cern.ch/t/putting-an-integer-variable-in-the-x-axis-label-of-a-1d-histogram/40705/1 "2020-07-29T01:25:17Z")

</div>

So I have a 1D histogram defined like this:

> TH1D\* h = new TH1D(“h”,“h;pT [GeV];number of events/bin width”,5,0,10)

where the bin width is just here as a placeholder for a double type number that I want to replace with its actual value. Could anyone help me with this?

_ROOT Version:_ 5.18  
_Platform:_ Ubuntu 18.04  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [July 29, 2020, 7:30am UTC](https://root-forum.cern.ch/t/putting-an-integer-variable-in-the-x-axis-label-of-a-1d-histogram/40705/2 "2020-07-29T07:30:58Z")

</div>

Hi @hep_1,  
Use [`TString::Format`](https://root.cern.ch/doc/master/classTString.html#ac34bbb89627e20624a416dfbb7a3db70) to insert a title with the values you need.  
Cheers,  
Vincenzo

---

<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:** [July 29, 2020, 8:26am UTC](https://root-forum.cern.ch/t/putting-an-integer-variable-in-the-x-axis-label-of-a-1d-histogram/40705/3 "2020-07-29T08:26:14Z")

</div>

```auto
TH1D* h = new TH1D("h", Form("h;pT [GeV];number of events/%d",bin_width), 5, 0, 10);

```
