# User-defined TF1 plotting only in certain range, not all ranges

**URL:** <https://root-forum.cern.ch/t/user-defined-tf1-plotting-only-in-certain-range-not-all-ranges/58239>\
**Category:** Newbie\
**Created:** [February 22, 2024, 8:38am UTC](https://root-forum.cern.ch/t/user-defined-tf1-plotting-only-in-certain-range-not-all-ranges/58239 "2024-02-22T08:38:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shailesh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@Shailesh](https://root-forum.cern.ch/u/Shailesh)\
**Post date:** [February 22, 2024, 8:38am UTC](https://root-forum.cern.ch/t/user-defined-tf1-plotting-only-in-certain-range-not-all-ranges/58239/1 "2024-02-22T08:38:24Z")

</div>

Hi All

I am trying to fit a user-defined function on some points using TF1. But by plotting it in certain ranges (I need -150 to -110 but I have tried other range as well), it gives the errors:

```auto

Warning in <TCanvas::ResizePad>: Inf/NaN propagated to the pad. Check drawn objects.
Warning in <TCanvas::ResizePad>: c1 height changed from 0 to 10

Warning in <TCanvas::ResizePad>: Inf/NaN propagated to the pad. Check drawn objects.
Warning in <TCanvas::ResizePad>: c1 height changed from 0 to 10

```

If i change the range to (-150, +101), it plots fine. But even at -150 to 100, it doesn’t plot.

I tried plotting just the TF1 in a different macro, but it gives the same error. For clarity I have attached the macro here. Can someone explain me what’s going on here?

I am using ROOT v6.26.04 on Ubuntu.  
[customizeHistogram.C](https://root-forum.cern.ch/uploads/short-url/rDt67h3t2hxId9kojGq8fjb3snq.C) (264 Bytes)

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [February 22, 2024, 9:59am UTC](https://root-forum.cern.ch/t/user-defined-tf1-plotting-only-in-certain-range-not-all-ranges/58239/2 "2024-02-22T09:59:49Z")

</div>

Try adding

```auto
    f1->SetNpx(99);

```

before drawing the TF1. The 1-D functions are drawn by default with 100 points in x, and for some reason this doesn’t work for your case (maybe a developer should look at why), but reducing the number of points like above, works here for the range (-150,100); increasing Npx didn’t seem to work in this example at least with several random values I tried.
