# Order of calling methods with TMultiGraph

**URL:** <https://root-forum.cern.ch/t/order-of-calling-methods-with-tmultigraph/14724>\
**Category:** ROOT\
**Created:** [August 7, 2012, 7:26pm UTC](https://root-forum.cern.ch/t/order-of-calling-methods-with-tmultigraph/14724 "2012-08-07T19:26:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![burnt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@burnt](https://root-forum.cern.ch/u/burnt)\
**Post date:** [August 7, 2012, 7:26pm UTC](https://root-forum.cern.ch/t/order-of-calling-methods-with-tmultigraph/14724/1 "2012-08-07T19:26:28Z")

</div>

I am drawing a TMultiGraph called total\_graph in a ROOT script using this piece of code:

total\_graph-\>Draw(“AL”);

total\_graph-\>SetTitle(“Charge State Probability”);

total\_graph-\>GetXaxis()-\>SetRangeUser(0, 200);  
total\_graph-\>GetYaxis()-\>SetRangeUser(0, 100);

total\_graph-\>Draw(“AL”);

If I take out the first line, total\_graph-\>Draw(“AL”), the interpreter complains about the GetXaxis() method. If I put the line, total\_graph-\>SetTitle() method just before the last line, total\_graph-\>Draw(“AL”), the title does not appear. Why does the order of these methods or whether the graph is drawn change whether they work or not?

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [August 7, 2012, 8:10pm UTC](https://root-forum.cern.ch/t/order-of-calling-methods-with-tmultigraph/14724/2 "2012-08-07T20:10:12Z")

</div>

I think that …

1. the first “Draw” creates axes (so they do not exist prior to this call)
2. there seems to exist a bug in ROOT related to “SetTitle” … a brutal fix …  
… if you “Draw” your TMultiGraph first, then use:  
total\_graph-\>GetHistogram()-\>SetTitle(“Charge State Probability”);  
… before the first “Draw”, use:  
total\_graph-\>SetTitle(“Charge State Probability”);

---

<div class="post-metadata">

**Author:** ![burnt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@burnt](https://root-forum.cern.ch/u/burnt)\
**Post date:** [August 8, 2012, 3:32pm UTC](https://root-forum.cern.ch/t/order-of-calling-methods-with-tmultigraph/14724/3 "2012-08-08T15:32:52Z")

</div>

A strange solution, but it works! Thanks. Where should I report this bug?

---

<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:** [August 30, 2012, 2:01pm UTC](https://root-forum.cern.ch/t/order-of-calling-methods-with-tmultigraph/14724/4 "2012-08-30T14:01:45Z")

</div>

The axis are created at drawing time.
