# TMultiGraph Axis bins and Zoom

**URL:** <https://root-forum.cern.ch/t/tmultigraph-axis-bins-and-zoom/19149>\
**Category:** ROOT\
**Created:** [April 24, 2015, 3:03am UTC](https://root-forum.cern.ch/t/tmultigraph-axis-bins-and-zoom/19149 "2015-04-24T03:03:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris\_s](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/chris_s/32/11632_2.png) [@chris\_s](https://root-forum.cern.ch/u/chris_s)\
**Post date:** [April 24, 2015, 3:03am UTC](https://root-forum.cern.ch/t/tmultigraph-axis-bins-and-zoom/19149/1 "2015-04-24T03:03:41Z")

</div>

Hi, I have a TMultigraph which contains a single TGraph that consists of approximately 100,000 points. I am attempting to zoom in the Xaxis to a specific region (using SetRange, not SetLimits, as the latter seems to break unzoom), but I am finding that the underlying histogram for the TMultigraph only contains 100 bins! Needless to say this is not enough to get a close view of a small subset of 100,000 points.

Here is an example:

```auto
{
const UInt_t N=100000;
Double_t x[N];
Double_t y[N];
for(int i=0;i<N;i++) {x[i]=i;y[i]=i+1;}
TMultiGraph* mg = new TMultiGraph("mg","mg");
TGraph* gr = new TGraph(100000,x,y);
mg->Add(gr);
mg->Draw("al");
cout<<mg->GetXaxis()->GetNbins()<<endl;
}
```

Output: 100

Interestingly if I do gr-\>Draw(“al”) then gr-\>GetXaxis()-\>GetNbins(), I get 100000 as expected. However, I wish to have this graph contained in a TMultiGraph in case I want to add more graphs in the future.

How can I force TMultiGraph to use more bins?

Chris

---

<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:** [April 24, 2015, 7:04am UTC](https://root-forum.cern.ch/t/tmultigraph-axis-bins-and-zoom/19149/2 "2015-04-24T07:04:24Z")

</div>

I found the issue and I will fix it in root trunk.  
It is easy to bypass by adding a first graph. The problem shows up because you have only one graph.

```auto
{
   const UInt_t N=100000;
   Double_t x[N];
   Double_t y[N];
   for(int i=0;i<N;i++) {x[i]=i;y[i]=i+1;}
   TMultiGraph* mg = new TMultiGraph("mg","mg");
   TGraph* g1 = new TGraph(1); g1->SetPoint(0,0.,0.); mg->Add(g1);
   TGraph* gr = new TGraph(100000,x,y);
   mg->Add(gr);
   mg->Draw("a*");
   cout<<mg->GetXaxis()->GetNbins()<< " "<< gr->GetXaxis()->GetNbins() <<endl;
}
```

---

<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:** [April 24, 2015, 7:14am UTC](https://root-forum.cern.ch/t/tmultigraph-axis-bins-and-zoom/19149/3 "2015-04-24T07:14:03Z")

</div>

Now fixed. Thanks for reporting.

---

<div class="post-metadata">

**Author:** ![chris\_s](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/chris_s/32/11632_2.png) [@chris\_s](https://root-forum.cern.ch/u/chris_s)\
**Post date:** [April 24, 2015, 8:33pm UTC](https://root-forum.cern.ch/t/tmultigraph-axis-bins-and-zoom/19149/4 "2015-04-24T20:33:32Z")

</div>

Thank you for the fix and providing a workaround.

Cheers,  
Chris

---

<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:** [April 27, 2015, 7:54am UTC](https://root-forum.cern.ch/t/tmultigraph-axis-bins-and-zoom/19149/5 "2015-04-27T07:54:14Z")

</div>

Not fixed in v5-34-00-patches.

---

<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:** [April 27, 2015, 7:54am UTC](https://root-forum.cern.ch/t/tmultigraph-axis-bins-and-zoom/19149/6 "2015-04-27T07:54:59Z")

</div>

> [@](#):
>
> I found the issue and I will fix it in root trunk.
