TGraph2D with predefined axis-range?

…interesting…took me a while to figure this out:

I tried to create a minimal example and wasn’t able to reproduce the error, now I got it.
I’m drawing the histro and graph inside a Loop()-method, which was initially created by TTree::MakeClass.

Seems that some directories and paths are bent when using these constructions - I had a similar issue in the past (see here: Histograms not drawn inside Looper-Class)

indeed

gROOT->cd(); 

before histocreation solves the issue.
Same applies to

h->SetDirectory(NULL);

after histocreation.
I was wondering why

TFile *outfile = new TFile("out.root","RECREATE");
TDirectory *dir = outfile;
dir->cd();

before the histocreation is not working

Georg