# Using Form() with the SetTitle() while graphing inside loop

**URL:** <https://root-forum.cern.ch/t/using-form-with-the-settitle-while-graphing-inside-loop/58811>\
**Category:** Newbie\
**Tags:** root\
**Created:** [April 1, 2024, 8:02pm UTC](https://root-forum.cern.ch/t/using-form-with-the-settitle-while-graphing-inside-loop/58811 "2024-04-01T20:02:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [April 1, 2024, 8:02pm UTC](https://root-forum.cern.ch/t/using-form-with-the-settitle-while-graphing-inside-loop/58811/1 "2024-04-01T20:02:57Z")

</div>

Is it somehow possible to use `Form()` while setting TGraph title using the ‘shorthand’ method

```auto
gr->SetTitle ("Form("Graph %d", graph_num); X title; Y title")

```

Or I need to resort to separate titles for the axes and the total graph?

Thanks a lot

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [April 1, 2024, 8:23pm UTC](https://root-forum.cern.ch/t/using-form-with-the-settitle-while-graphing-inside-loop/58811/2 "2024-04-01T20:23:41Z")

</div>

`Form` uses a static buffer is not advisable in function calls. Instead use `TString::Format`:

```auto
gr->SetTitle (TSring::Format("Graph %d; X title; Y title", graph_num).Data());

```
