# Plotting from Interpolation

There is a list

{{5.667680905429296, 4.978997738176498}, {6.062672641119444, 4.821312039084925}, {6.463307024854181, 4.616923216296398}, {6.869389071217502, 4.358024801663491}, {7.280737790273085, 4.0328205724875374}, {7.697184816760531, 3.6220668338026347}, {8.118573184417112, 3.090204786097973}, {8.544756235833926, 2.354492374103027}, {8.97559665513716, 1.045159976700232}, {9.168625618559851, 6.355895552341976^-16}, {9.291801857401657, 6.34776334121662^-20}}

in the form {x,y}. I interpolate the list using Data=Interpolation[{x,y}]. I want to plot the interpolated function as the dependence y(x). How can it be done?

Writing:

points = {{5.667680905429296, 4.978997738176498},
{6.062672641119444, 4.821312039084925},
{6.463307024854181, 4.616923216296398},
{6.869389071217502, 4.358024801663491},
{7.280737790273085, 4.0328205724875374},
{7.697184816760531, 3.6220668338026347},
{8.118573184417112, 3.090204786097973},
{8.544756235833926, 2.354492374103027},
{8.97559665513716, 1.045159976700232},
{9.168625618559851, 6.355895552341976^-16},
{9.291801857401657, 6.34776334121662^-20}};

f = Interpolation[points, InterpolationOrder -> 2];

Plot[f[x], {x, points[[1, 1]], points[[11, 1]]},
Epilog -> Point[points],
AxesLabel -> {x, y}]


I get:

which is what you want.

• Why is it not smooth? – Tursinbay Jul 12 '17 at 14:49
• Through InterpolationOrder you can choose the type of interpolation: linear, quadratic, ... – TeM Jul 12 '17 at 14:56

You might want to use InterpolationOrder

ListLinePlot[points, InterpolationOrder -> 2, Mesh -> Full]


Here shows the resulting curves and smoothness of the Interpolation with change in the degree of the polynomial from 0 to 5

Plot[Evaluate@Interpolation[points, InterpolationOrder -> #][x], {x,
points[[1, 1]], points[[11, 1]]}, Epilog -> Point[points],
AxesLabel -> {x, y}] & /@ {1, 2, 3, 4, 5}


Here are the results

Also, by taking a good look at the first derivative is a good indication of where in the independent variable x range may need further additional points to get a good quality interpolation.

   f = Interpolation[points]; {xmin, xmax} =
MinMax[points[[All, 1]]]; Plot[{f[x], f'[x]}, {x, xmin, xmax},
AspectRatio -> 2, PlotLegends -> "Expressions"]


• The yellow curve is the 1st derivative of the interpolation function, but I do not know how to correctly label this in WM – Jose Enrique Calderon Jul 12 '17 at 16:05
• f = Interpolation[points]; {xmin, xmax} = MinMax[points[[All, 1]]]; Plot[{f[x], f'[x]}, {x, xmin, xmax}, PlotLegends -> "Expressions"] – Bob Hanlon Jul 12 '17 at 16:19
• Thank you Bob.. but this just place the Interpolation function . I really need to use a custom label ( f(x) and f'(x) ) – Jose Enrique Calderon Jul 12 '17 at 17:14
• With the code that I posted the PlotLegend shows f(x) and f'(x), Perhaps you need to Clear[f]. – Bob Hanlon Jul 12 '17 at 17:20