# InterpolationOrder 2 or more in ListLogLinearPlot

I'm using the function ListLogLinearPlot, but the plot is to square, i would like to have InterpolationOrder 2, but there is not this command for the function.

I tried to make my own interpolation, creating a function which create more points between my pre-existing points:

Int1[p0_, n0_] :=
Module[{p = p0, n = n0, i, j, a, b, l = {}, x, y},
Table[
a = (p[[i + 1, 1]] - p[[i, 1]])/(n + 1);
b = (p[[i + 1, 2]] - p[[i, 2]])/(n + 1);
Table[
x = p[[i, 1]] + a*j;
y = p[[i, 2]] + b*j;
AppendTo[l, {x, y}];
, {j, 0, n}
]
, {i, 1, Length[p] - 1}
];
AppendTo[l, p[[-1]]];
l
]
nn = 3;
Int1[Points, nn];


But, i can't make it works

@MarcoB

PSt = {RGBColor[0, 0.5, 0.8],
Thickness[0.005]}; PSa = {RGBColor[0.5, 0.5, 0.5], Thickness[0.003]};
PSb = {RGBColor[0.3, 0.3, 0.3],
Thickness[0.002]}; PSc = {RGBColor[0.3, 0.3, 0.3], Thickness[0.001]};

FinosCA = {{0, 0}, {0.15, 2}, {0.3, 10}, {0.6, 25}, {1.18, 50}, {2.36,
80}, {4.75, 95}, {9.5, 100}};
FinosCB = {{0, 0}, {0.15, 10}, {0.3, 30}, {0.6, 60}, {1.18,
85}, {2.36, 100}, {4.75, 100}, {9.5, 100}};
FinosCC = {{0, 0}, {0.15, 10}, {0.3, 50}, {0.6, 95}, {1.18,
100}, {2.36, 100}, {4.75, 100}, {9.5, 100}};
FinosCM = {{0, 0.34}, {0.15, 2.6}, {0.3, 26.68}, {0.6, 96.60}, {1.18,
99.64}, {2.36, 99.94}, {4.75, 100}, {9.5, 100}};
nn = 50
ListLogLinearPlot[{FinosCA, FinosCB, FinosCC, FinosCM},
Joined -> True, AspectRatio -> 1/GoldenRatio,
AxesLabel -> {"Diamentro de malla\ndel tamiz [mm]",
"% Pasante Acumulado"}, LabelStyle -> Directive[FontSize -> 14],
ImageSize -> 650, PlotStyle -> {PSa, PSb, PSc, PSt}]
ListLogLinearPlot[{Int1[FinosCA, nn], Int1[FinosCB, nn],
Int1[FinosCC, nn], Int1[FinosCM, nn]}, Joined -> True,
AspectRatio -> 1/GoldenRatio,
AxesLabel -> {"Diamentro de malla\ndel tamiz [mm]",
"% Pasante Acumulado"}, LabelStyle -> Directive[FontSize -> 14],
ImageSize -> 650, PlotStyle -> {PSa, PSb, PSc, PSt}]


• Could you include your existing points, the code you have used so far, and maybe an example of output? Jul 3, 2015 at 20:32
• @MarcoB I changed the post Jul 3, 2015 at 20:44
• Gonzalo, thanks for the update. Could you expand a little on what exactly you would like to accomplish as well? I'm afraid that I did not completely understand what you need to do. Do you want a "smoother" plot? Or do you want perhaps a fit function? Jul 3, 2015 at 20:46
• @MarcoB i want... a curve line instead of a rect-poliline Jul 3, 2015 at 20:51
• @MarcoB yes, i want a "smoother" plot Jul 3, 2015 at 20:58

You can get a smoother result by taking the Log before making the interpolation:

loginterp[x_] =
Interpolation[{Log10[#1], #2} & @@@ Rest@#, InterpolationOrder -> 2][Log10[x]] & /@
{FinosCA, FinosCB, FinosCC, FinosCM};

Show[
LogLinearPlot[Evaluate@loginterp[x], {x, FinosCA[[2, 1]], FinosCA[[-1, 1]]}],
ListLogLinearPlot[{FinosCA, FinosCB, FinosCC, FinosCM}]
]


Without taking the Log first, you'll get more spurious wiggles, even when using the "Spline" method:

interp[x_] = Interpolation[#, InterpolationOrder -> 2, Method -> "Spline"][x] & /@
{FinosCA, FinosCB, FinosCC, FinosCM};

Show[
LogLinearPlot[Evaluate@interp[x], {x, FinosCA[[2, 1]], FinosCA[[-1, 1]]}],
ListLogLinearPlot[{FinosCA, FinosCB, FinosCC, FinosCM}]
]


You can add the options InterpolationOrder -> 2 and PlotRange -> {0.1, 110} to your ListLogLinearPlot. As all your data points start at 0, you have to remove these using Rest.

ListLogLinearPlot[{Rest@FinosCA, Rest@FinosCB, Rest@FinosCC, Rest@FinosCM},
Joined -> True, AspectRatio -> 1/GoldenRatio,
AxesLabel -> {"Diamentro de malla\ndel tamiz [mm]", "% Pasante Acumulado"},
LabelStyle -> Directive[FontSize -> 14], ImageSize -> 650,
PlotStyle -> {PSa, PSb, PSc, PSt}, InterpolationOrder -> 2, PlotRange -> {0.1, 110}]


I propose to use the build-in interpolating function Interpolation which is a continuous function, and then to make sampling at higher frequency :

FinosCA = {{0, 0}, {0.15, 2}, {0.3, 10}, {0.6, 25}, {1.18, 50}, {2.36,
80}, {4.75, 95}, {9.5, 100}};;

interpolatingFunction = Interpolation[FinosCA, InterpolationOrder -> 2];

n = 10; (* number of new points betwen initial points *)
newPointsAbcissa =
Flatten[Range[#[[1]], #[[2]], (#[[2]] - #[[1]])/(n + 1)] & /@
Partition[First /@ FinosCA, 2, 1]];

Show[
ListLogLinearPlot[
Table[
{x, interpolatingFunction[x]},
{x,newPointsAbcissa}
]],
ListLogLinearPlot[FinosCA,
PlotStyle -> {Red, PointSize[0.03], Point[FinosCA]}]
]


In red : the initial points.

EDIT

Of course, if you don't need the intermediate points, you can plot directly the continuous interpolating function. Here is the code :

{xmin, xmax} = {Min[#], Max[#]} & @ (First /@ Rest[FinosCA])
LogLinearPlot[interpolatingFunction[x], {x, xmin, xmax}]


Note : I have removed the first point of FinosCA (see code Rest[FinosCA] above) which is {0,0} and is -Infinity on a Log scale.

EDIT

The cusp is removed if you use the option Method -> "Spline" :

interpolatingFunction =
Interpolation[FinosCA, InterpolationOrder -> 2, Method -> "Spline"];


• Once you have interpolatingFunction why not directly call LogLinearPlot?
– user484
Jul 3, 2015 at 21:01
• @Rahul : you could, of course, but I think that this presentation is more in the spirit of the question : one can see here how to re-sample (one say up-sample ?) irregular data. Jul 3, 2015 at 21:06
• @Rahul I have added the LogLinearPlot solution Jul 3, 2015 at 21:41