# Automatic PlotRange based on Interpolation results

Persisting through 11.3, fixed in Mathematica 12.0

We generally use PlotRange->All to see all available points in a plot. But how do you use PlotRange when you want to run it with functions like the below without facing any data clippings.

This is best explained with a MWE:

data = {{1, 0.542399}, {2, 1.45729}, {3, 1.38588}, {4, 1.29452}, {5,
3.59352}, {6, 3.6808}, {7, 5.92152}, {8, 0.780593}, {9,
7.91613}, {10, 5.2081}};


Plot#1: general usage

ListLinePlot[data,
Epilog -> {Green, Line[data], PointSize[Medium], Red, Point[data]},
InterpolationOrder -> 2, PlotRange -> All, GridLines -> Automatic]


Plot#2: Manually defined limits for x and y axis

ListLinePlot[data,
Epilog -> {Green, Line[data], PointSize[Medium], Red, Point[data]},
InterpolationOrder -> 2, PlotRange -> {{1, 10}, {0.1, 10}},
GridLines -> Automatic]


• a simpler MWE ListLinePlot[data, InterpolationOrder -> 2, PlotRange->All]
– kglr
Nov 1 '18 at 17:50
• Looks like a glitch introduced in v10 or later (the issue doesn't arise in version 9 -windows 10).
– kglr
Nov 1 '18 at 17:52
• @kglr Damn! Looks like I have a knack to just find glitches. Or whatever I want happens to be a glitch. Nov 1 '18 at 20:08
• Certainly a bug in ListPlot, please report it to the support. Nov 2 '18 at 8:45

## 1 Answer

Clipping has nothing to do with the interpolation: PlotRange is defined based on the plotted data which in this case does not involve interpolated datapoints. I'm not sure if this is a bug or a feature: the displayed spline is obviously not sampled to find its extrema, but this could be by design. Furthermore (not really relevant here, but important) if you include anything in the Epilog or Prolog, those are also not used when calculating PlotRange.

I suggest using an explicit PlotRange, but you can also incorporate the linear and splined functions in one plot:

data = {{1, 0.542399}, {2, 1.45729}, {3, 1.38588}, {4, 1.29452},
{5, 3.59352}, {6, 3.6808}, {7, 5.92152}, {8, 0.780593},
{9, 7.91613}, {10, 5.2081}};
Plot[{
Interpolation[data, InterpolationOrder -> 1][t],
Interpolation[data, InterpolationOrder -> 2, Method -> "Spline"][t]
}, {t, 1, 10}, PlotRange -> All, Epilog -> {Red, Point@data}]