Fit Line Is Not Shown

My one fitline is shown on graph and another is not .Why ?

 void fits()
{

   const int ndata = 19; // Adjusted to match the new number of data points

   float x[ndata] = {0.0,   0.0754, 0.1471, 0.2207, 0.2941, 0.3778, 0.4600, 0.5790, 0.7500, 0.8950,
                     1.065, 1.204,  1.350,  1.510,  1.712,  1.933,  2.121,  2.463,  2.765};

   float y[ndata] = {410.0e-12, 295.0e-12, 194.0e-12, 124.6e-12, 70.0e-12,  27.5e-12,  1.0e-12,
                     -23.0e-12, -37.0e-12, -46.0e-12, -50.0e-12, -52.0e-12, -54.0e-12, -55.0e-12,
                     -56.5e-12, -59.0e-12, -60.5e-12, -63.0e-12, -65.0e-12};

   float sx[ndata] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1};

   float sy[ndata] = {1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12,
                      1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12};

   TCanvas *c1 = new TCanvas("c1", "Fit Subranges", 200, 10, 700, 500);

   gStyle->SetOptFit(1111);

   TGraphErrors *graph = new TGraphErrors(ndata, x, y, sx, sy);

   graph->SetTitle("Green Light;X;Y");

   graph->SetMarkerStyle(21);

   graph->Draw("AP");

   // Define fits with clear distinction

   TF1 *fit1 = new TF1("fit1", "pol1", x[0], x[18]); // Adjust the drawing range to be more visible

   fit1->SetLineColor(kBlue);

   fit1->Draw("L SAME");

   TF1 *fit2 = new TF1("fit2", "pol1", x[0], x[18]); // Adjust the drawing range

   fit2->SetLineColor(kRed);

   fit2->Draw("L SAME");

   // Perform the fits

   graph->Fit(fit1, "R", "", x[0], x[5]); // First subrange

   graph->Fit(fit2, "R+", "", x[14], x[18]); // Second subrange

   // Intersection calculation remains unchanged

   double m1 = fit1->GetParameter(1); // Slope of the first fit

   double b1 = fit1->GetParameter(0); // Intercept of the first fit

   double m2 = fit2->GetParameter(1); // Slope of the second fit

   double b2 = fit2->GetParameter(0); // Intercept of the second fit

   double x_intercept = (b2 - b1) / (m1 - m2);

   double y_intercept = m1 * x_intercept + b1;

   std::cout << "Intersection point: (" << x_intercept << ", " << y_intercept << ")" << std::endl;

   // Draw a marker at the intersection point

   TGraph *intPoint = new TGraph(1, &x_intercept, &y_intercept);

   intPoint->SetMarkerStyle(29);

   intPoint->SetMarkerColor(kGreen);

   intPoint->Draw("P SAME");

   double x_intersect_zero = (b1 - b2) / (m2 - m1);

   std::cout << "Intersection point where y = 0: (" << x_intersect_zero << ", 0)" << std::endl;

   // Draw a marker at the intersection point where y = 0

   TMarker *intPointZero = new TMarker(x_intersect_zero, 0, 29);

   intPointZero->SetMarkerColor(kMagenta);

   intPointZero->Draw();

   c1->Update();
}

Dear Sinem,

Welcome to the ROOT community!
Thanks for sharing this reproducer.
Are you sure the second fit is succeeding? This is the output I get:

Minimizer is Minuit2 / Migrad
Chi2                      =      0.29687
NDf                       =            3
Edm                       =  7.84439e-08
NCalls                    =          189
p0                        = -4.33796e-11   +/-   3.88521e-12 
p1                        = -7.92264e-12   +/-   1.74188e-12 

Best,
D

   graph->Fit(fit1, "R EX0", "", x[0], x[5]); // First subrange

   graph->Fit(fit2, "R EX0 +", "", x[14], x[18]); // Second subrange

Read here this might help.