How to fit a function parallel to the Y-axis

Hi rooters!

Apologies if this is a stupid question, but I can’t wrap my head around the following problem: In an MC set-up, I am trying to fit a TF1-function to points in a TGraph, s.th. such as

TGraphErrors* ClusterCentres = new TGraphErrors();
...
TF1 *myLine = new TF1("track", "[0]*x+[1]", 0, myMax);
...
ClusterCentres->Fit("track");

Due to the nature of the problem I handle, it is pretty likely though that all points in the TGraph are “vertical”, i.e. parallel to the Y-axis – in this case, the fit function I use, namely f(x)=m * x + b, is not very suited. In good old grade-six-tradition, I would prefer to use a function such as f(y)=m’ * y + b’. But using

TF1 *myLine = new TF1("track", "[0]*y+[1]", 0, myMax);

does not work; I get

Error in <TF1::TF1>: function: track/y*[0]+[1] has 2 parameters instead of 1

as an error message. I am sure there’s a way to make ROOT just fit a vertical function – and I would be quite grateful if anyone could give me a tip! Thanks in advance!

Try: TGraphErrors *ClusterCentresSwapped = new TGraphErrors( ClusterCentres->GetN(), ClusterCentres->GetY(), ClusterCentres->GetX(), ClusterCentres->GetEY(), ClusterCentres->GetEX() ); ClusterCentresSwapped->Fit("pol1");

Thanks!!! I wondered about this nasty work-around already.
It technically seems to work, however, I don’t really like it >.<

Is there a way to plot the function rotated? Now, of course, it is displayed with the axes exchanged… So I have to convert s.th. like m->1/m, b->-b/m