# TF1 linear fit (pol1): Fitted line is not smooth

**URL:** <https://root-forum.cern.ch/t/tf1-linear-fit-pol1-fitted-line-is-not-smooth/53134>\
**Category:** Newbie\
**Tags:** roofit, hist, root\
**Created:** [January 17, 2023, 5:47am UTC](https://root-forum.cern.ch/t/tf1-linear-fit-pol1-fitted-line-is-not-smooth/53134 "2023-01-17T05:47:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thegame](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/e495f1/32.png) [@thegame](https://root-forum.cern.ch/u/thegame)\
**Post date:** [January 17, 2023, 5:47am UTC](https://root-forum.cern.ch/t/tf1-linear-fit-pol1-fitted-line-is-not-smooth/53134/1 "2023-01-17T05:47:40Z")

</div>

Hi all, I’m trying to perform a linear fit over a selected region in my plot. The macro is running successfully and giving desirable output;  
used something like this to FIT:

```auto
TF1 *fit2 = new TF1("fit2", "pol1");
hist2->Fit("fit2","","",0.036,0.041);

```

However, the fitted line in the plot is not smooth instead it’s some sort of step line chart. Wanna know what is the reason for this and how to make it a smooth straight line? Attached is the plot for the same in case you wanna look at the fit.

Thanks!!

 ![FitROOT.png](https://root-forum.cern.ch/uploads/default/original/3X/6/a/6a938af8d6fa5a91df518959bc8af735d5122885.png)

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [January 17, 2023, 7:30am UTC](https://root-forum.cern.ch/t/tf1-linear-fit-pol1-fitted-line-is-not-smooth/53134/2 "2023-01-17T07:30:50Z")

</div>

Try to increase the number of points using [TF1::SetNpx()](https://root.cern.ch/doc/master/classTF1.html#a6a04facaa58306988a3189b4e8713aa5).

Add after the fit2 declaration the line

```auto
fit2->SetNpx(500);

```

Stefano
