# Changing TMultiGraph Axis range results in bus error

**URL:** <https://root-forum.cern.ch/t/changing-tmultigraph-axis-range-results-in-bus-error/15567>\
**Category:** ROOT\
**Created:** [January 31, 2013, 12:20am UTC](https://root-forum.cern.ch/t/changing-tmultigraph-axis-range-results-in-bus-error/15567 "2013-01-31T00:20:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![emza0114](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/d26b3c/32.png) [@emza0114](https://root-forum.cern.ch/u/emza0114)\
**Post date:** [January 31, 2013, 12:20am UTC](https://root-forum.cern.ch/t/changing-tmultigraph-axis-range-results-in-bus-error/15567/1 "2013-01-31T00:20:35Z")

</div>

Hi rooters

I am getting a bus error when I attempt to change the range of the x-axis of a multigraph which is stored in a root file. The method I call is `multi_gr->GetXaxis()->SetLimits(10.0,100.0)` which is the source of the error. In fact I can’t seem to call any methods in TAxis without my code crashing.

The full code is

```auto
 void DrawGraph(){
  TFile *file = new TFile("fitted_graphs.root","READ");
  
  TMultiGraph *multi_gr;
  char *Title;
  string str = "state_fidelity_";
  string pdf_title = str+"plots.pdf";
  Title = new char [pdf_title.size()];
  
  TCanvas *c = new TCanvas("comp","Plots", 300, 200); 
  
  gStyle->SetOptFit(1111);
  char * Tplotname = new char [str.size()+2];
  
  ostringstream temp_string;	 
  temp_string<<str;
  temp_string<<1;
  
  strcpy (Tplotname, (temp_string.str()).c_str());	 
  
  file->GetObject(Tplotname,multi_gr);
  
  multi_gr->SetMaximum(1.0);
  multi_gr->SetMinimum(0.0000001);
  multi_gr->GetXaxis()->SetLimits(10.0,100.0);
  
  c->SetLogy();
  c->SetLogx();
  multi_gr->Draw("ap");
  gStyle->SetOptFit(1111);
  c->BuildLegend();
  c->Print(pdf_title.c_str());
  
  delete c;
  delete Title;
  delete file; 
}
```

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 31, 2013, 6:45am UTC](https://root-forum.cern.ch/t/changing-tmultigraph-axis-range-results-in-bus-error/15567/2 "2013-01-31T06:45:43Z")

</div>

` if (multi_gr) { // make sure it really exists
    multi_gr->Draw("ap"); // draw it
    gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn;
    multi_gr->SetMaximum(1.0);
    multi_gr->SetMinimum(0.0000001);
    multi_gr->GetXaxis()->SetLimits(10.0,100.0);
    gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn;
  } else {std::cout << "Error : multi_gr == 0" << std::endl;}`
