Fitting

Hi rooters!!

I would like ask you if there is a method for extend a line produced by a fit, because I have a graph, but the fit it is for only some points of graph, so I restrict the area near to these points with a fit panel, but then I would like that the fit line continues, with the same trend, until the end of graph, let say until the axis, in the top and bottom. There is an example, the red line is a fit line, and I would like thant continue. How can I do?

Thanks a lot

Hi

I usually create another instance for the extended line and use the same parameter
from the partial fit.

Do you mean that you plot a new function superimpose by fit line?

That’s one way.
I prefer first fit without drawing and take the parameters only to draw with new function.

Try the “N” fit option.

No with “N” doesn’t draw a fit line.
I have tried also to set the range, but don’t work.
The solution could be draw a TF1 obtained from fit parameters, but the problem it is that when I draw the function disappear the graph, and viceversa. I have tried also with a TMultigraph but with the same result. Someone know how draw a function into the TGraph?

thanks

Do you have a small reproducer ?

The example it is in my first post, as you see the fit linee is not continue until the axis, so with the fit parameters I can obtain a parameters to have a line function. But the problem is that I can’t draw at the same time both the graph and the function.

You posted a picture but not a piece of code reproducing your problem.

Try something like:
SomeTGraph->Draw(“A*”);
SomeTF1->Draw(“LSAME”); // draw on top of an existing picture

Oh sorry I thinked you mean a picture… So the code is:

{
   TGraph *gr = new TGraph ("2016.03.10-16.00.00_2016.03.11-23.40.00_OFF_0_0_Current.csv", "%*s %*s %*s %*s %*s %*s %lg %lg")
   gr->Draw("APL")
 
   TF1 *f1 = new TF1 ("f1", "-0.013487+(0.0000015*x)")
   f1->Draw("LSAME")
}

I have tried also to put the option “SAME” like told Pepe Le Pew, when I draw the function but doesn’t work.

Attach your data file here.

This is an example of data:

2016.03.10	16:43:55	1	1	0	492	500.368272727	0	1.13071008593e-06	0
2016.03.10	16:48:55	1	1	0	984	1000.726	1.55476564823e-07	1.61126187246e-05	3.96738649605e-07
2016.03.10	16:53:55	1	1	0	1475	1500.18727273	1.39928908341e-06	6.33197648123e-05	2.42010576259e-05
2016.03.10	16:58:55	1	1	0	1967	2000.47162162	6.93341437724e-07	6.30294473578e-05	2.35898656522e-05
2016.03.10	17:03:55	1	1	0	2458	2499.81472727	7.77382824115e-07	9.4131614654e-05	6.66520931336e-05
2016.03.10	17:08:55	1	1	0	2950	3000.15545455	7.77382824115e-07	0.0001096789	8.84727188619e-05
2016.03.10	17:13:55	1	1	0	3441.4	3499.91890909	1.55476564823e-06	0.0001410561	0.0001170379
2016.03.10	17:18:30	1	1	0	3933	3999.635	9.16201185564e-07	0.0001560279	0.000132872
2016.03.10	17:23:55	1	1	0	4425	4499.99781818	9.17311732456e-06	0.0001729986	0.0001773422
2016.03.10	17:28:30	1	1	0	4917	4999.93964286	8.39851086767e-06	0.0002015592	0.0002108028
2016.03.10	17:33:55	1	1	0	5409	5499.98345455	1.0572406408e-05	0.0002351877	0.0002424073
2016.03.10	17:38:30	1	1	0	5901	5999.99642857	8.55121106527e-06	0.0002640259	0.0002828888
2016.03.10	17:44:00	1	1	0	6393	6499.83636364	9.17311732456e-06	0.000311228	0.0003086627
2016.03.10	17:49:00	1	1	0	6886	7000.408	1.72578986954e-05	0.0003575871	0.0003495268
2016.03.10	17:53:40	1	1	0	6984	7099.76491525	1.31891560498e-05	0.0003575871	0.0003598554
2016.03.10	17:58:40	1	1	0	7083	7199.89169492	1.72473579113e-05	0.0003583776	0.0003713205
2016.03.10	18:03:40	1	1	0	7182	7300.14610169	1.75372294728e-05	0.0003744519	0.0003727998
2016.03.10	18:08:40	1	1	0	7280	7399.69101695	2.52188258535e-05	0.0004042289	0.0003927713
2016.03.10	18:13:40	1	1	0	7379	7499.79813559	2.60884405381e-05	0.0004044924	0.0003935109
2016.03.10	18:18:40	1	1	0	7478	7600.36	3.42048442611e-05	0.0004197761	0.0003949903
2016.03.10	18:23:40	1	1	0	7576	7699.90711864	3.53643305072e-05	0.0004297896	0.0004160713
2016.03.10	18:28:40	1	1	0	7675	7800.19322034	3.92775965879e-05	0.0004369045	0.0004390014
2016.03.10	18:33:35	1	1	0	7773	7899.38066667	4.83143425188e-05	0.0004594216	0.0004578695
2016.03.10	18:38:40	1	1	0	7873	8000.99305085	5.33363673223e-05	0.0004830192	0.000460822
2016.03.10	18:43:35	1	1	0	7971	8100.21583333	6.15687196699e-05	0.0004824834	0.0004611426
2016.03.10	18:48:40	1	1	0	8070	8200.41084746	7.88450647374e-05	0.0005141138	0.0004830125
2016.03.10	18:53:35	1	1	0	8168	8300.28666667	8.53695904683e-05	0.0005283478	0.0005015107
2016.03.10	18:58:45	1	1	0	8267	8400.63672414	9.92235352918e-05	0.0005441542	0.0005116561
2016.03.10	19:03:35	1	1	0	8366	8500.01366667	0.000116154	0.0005747305	0.000524786
2016.03.10	19:08:45	1	1	0	8464	8600.07016949	0.0001411675	0.000590796	0.0005495839
2016.03.10	19:13:45	1	1	0	8563	8700.77525424	0.0001639224	0.0006218905	0.0005673363
2016.03.10	19:18:45	1	1	0	8661	8800.13711864	0.0001911703	0.0006466608	0.0005839791
2016.03.10	19:23:45	1	1	0	8760	8899.58559322	0.0002227663	0.0006685323	0.0006109775
2016.03.10	19:28:45	1	1	0	8858	8999.51813559	0.0002545072	0.0006996269	0.0006298394
2016.03.10	19:33:45	1	1	0	8957	9100.14457627	0.0003045101	0.0007465322	0.0006501807
2016.03.10	19:38:45	1	1	0	9055	9198.95118644	0.0003620496	0.0007773632	0.0006745902
2016.03.10	19:43:45	1	1	0	9155	9300.19677966	0.0004321985	0.0008371806	0.0006827267
2016.03.10	19:48:45	1	1	0	9253	9399.41084746	0.0005182904	0.0008912008	0.0007200806
2016.03.10	19:53:45	1	1	0	9352	9499.85322034	0.0006097448	0.0009610317	0.000758914
2016.03.10	19:58:45	1	1	0	9451	9600.89033898	0.0007193163	0.0010211127	0.0007825838
2016.03.10	20:03:40	1	1	0	9550	9700.65933333	0.0008554061	0.0011030784	0.000814273
2016.03.10	20:08:45	1	1	0	9648	9800.32322034	0.0010248409	0.0011863353	0.0008754139
2016.03.10	20:13:40	1	1	0	9747	9900.841	0.0011964569	0.001282131	0.0009041013
2016.03.10	20:18:45	1	1	0	9845	9999.92983051	0.0013850063	0.0013713214	0.0009453139
2016.03.10	20:23:40	1	1	0	10041	10199.0866667	0.0017642574	0.0015573176	0.0011361272

The columns that I want plot are the 7 and 8.

{
   TGraph *gr = new TGraph ("boog.csv", "%*s %*s %*s %*s %*s %*s %lg %lg");
   gr->Draw("APL");

   TF1 *f1 = new TF1 ("f1", "-0.013487+(0.0000015*x)",0,11000); 
   f1->SetLineColor(kRed);
   f1->Draw("LSAME");
}

Default limits for TF1 are 0,1… read the doc… its helps sometimes :wink:
root.cern.ch/doc/master/classTF1.html

Yes I forgot the limits!!! now work!!

Thank you a lot!! =)