How to set range of TF1 function with log scale


I try to set the range of a TF1 function with a log scale, but for example the following does not work:

root [0] TF1* f1 = new TF1("f1","exp(-x)",0.,5.);
root [1] TCanvas* fCanvas = new TCanvas("c1","canvas",800,600);
root [2] f1->Draw();
root [3] f1->GetYaxis()->SetRangeUser(0.,0.5);
root [4] fCanvas->SetLogx();
root [5] f1->GetYaxis()->SetRangeUser(0.,0.5);

Also, while in log scale I cannot zoom the x and y axis. The same works fine with histograms.
Is it a normal behavior? Or am I doing something wrong?

My root version is 5.34/32 and running on mac os x yosemite

thanks for your help

Range setting is based on the bins (on you case the axis values will be converted in bin).
The number of bin in the range you are using might be to small.
You can try to increase the number of bins for the function
Moreover you are using 0. as lower limit… Log(0.) is not valid