[quote]I tried doing ntuple->GetYaxis()->SetLimits(0, 0.5); but it doesn’t work. [/quote]The axis (and its limit) are not a properly of the ntuple. It is a property of the histogram.
ntuple->Draw("x1:sigma","randRange < 10 && sigma < 35");
htemp->GetYaxis()->SetLimits(0, 0.5);(but actually I think you mean to call htemp->SetMinimum and htemp->SetMaximum).
In my code, I don’t define any histogram, I just create the ntuple and use the Draw() function. Where should I define the histogram? And how do I draw my ntuple on it?
[quote]In my code, I don’t define any histogram[/quote]As you discovered, you indirectly defined an histogram named htemp when calling Draw.
Also CINT has a shortcut that let you replaceTH2F *htemp = (TH2F*)gPad->GetPrimitive("htemp"); // for 2D graphs; empty, but has axes
TAxis *yaxis = htemp->GetYaxis(); with just
TAxis *yaxis = htemp->GetYaxis(); (i.e. CINT can do the variable declaration and GetPrimitive automatically).