@@ -368,7 +368,7 @@ Let's show it on a simple example.
368368 yi1_n = csaps(x1, y, xi1, smooth=0.8, normalizedsmooth=True)
369369 yi2_n = csaps(x2, y, xi2, smooth=0.8, normalizedsmooth=True)
370370
371- f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(8 , 6))
371+ f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(10 , 6))
372372 ax1.plot(x1, y, 'o', xi1, yi1, '-')
373373 ax2.plot(x2, y, 'o', xi2, yi2, '-')
374374 ax3.plot(x1, y, 'o', xi1, yi1_n, '-')
@@ -406,14 +406,50 @@ The example for univariate data:
406406 yi1 = spline(xi1)
407407 yi2 = spline(xi2)
408408
409- f, (ax1, ax2) = plt.subplots(2, 1 , figsize=(5, 6 ))
409+ f, (ax1, ax2) = plt.subplots(1, 2 , figsize=(10, 4 ))
410410 ax1.plot(x, y, 'o', xi1, yi1, '.-')
411411 ax2.plot(x, y, 'o', xi2, yi2, '.-')
412412
413413 ax1.set_title('20 evaluated points')
414414 ax2.set_title('50 evaluated points')
415415
416416
417+ .. _tutorial-extrapolation :
418+
419+ Extrapolation
420+ ~~~~~~~~~~~~~
421+
422+ Spline values can be evaluated out-of-bounds input X-values (the input grid) based on first and last intervals.
423+ These values will be extrapolated. The ``extrapolate `` parameter in the spline evaluation method is used for this.
424+ Extrapolation can be used for all evaluated splines: univariate, multivariate and N-D grid.
425+
426+ Here is an example for univariate data:
427+
428+ .. plot ::
429+
430+ x, y = univariate_data()
431+ xi = np.linspace(x[0] - 2.0, x[-1] + 2.0, 50)
432+
433+ s1 = csaps(x, y, smooth=0.85)
434+ s2 = csaps(x, y, smooth=0.85)
435+
436+ yi1 = s1(xi, extrapolate=True)
437+ yi2 = s2(xi, extrapolate='periodic')
438+
439+ _, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 4))
440+ ax1.plot(x, y, 'o:', xi, yi1, '.-')
441+ ax2.plot(x, y, 'o:', xi, yi2, '.-')
442+
443+ ax1.set_title('extrapolate=True')
444+ ax2.set_title('extrapolate="periodic"')
445+
446+ .. attention ::
447+
448+ How we can see ``'periodic' `` extrapolation method works incorrectly with the spline. There is a discontinuity.
449+ This can be fixed in the future. Please see `the issue <https://github.com/espdev/csaps/issues/46 >`_ for details.
450+ So don't use this method for now if you need extrapolation.
451+
452+
417453.. _tutorial-analysis :
418454
419455Analysis
0 commit comments