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

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

Hi @hep_1,
Use TString::Format to insert a title with the values you need.

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