TMultiGraph Axis bins and Zoom

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:

{
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

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.

{
   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;
}

Now fixed. Thanks for reporting.

Thank you for the fix and providing a workaround.

Cheers,
Chris

Not fixed in v5-34-00-patches.