4
$\begingroup$

I have data in Mathematica that comes from y-log scale

Data = {{5.0, 23.87548081003781},
   {6.94392523364486, 0.511639358262082},
   {8.925233644859812, 0.23397526329810545},
   {10.962616822429906, 0.16190746961888203},
   {12.906542056074766, 0.17751810380557045},
   {14.925233644859812, 0.25653445869951874}};

These points should be connected by straight line on log scale like this

ListLogPlot[Data, Joined -> True]

I want to find interpolated function with straight lines on log plot(just like above code), however naive result gives me:

LogPlot[Interpolation[Data, InterpolationOrder -> 1][x], {x, 5, 14}]

which does not have straight lines on logPlot, it has straight lines on Plot.

How can I interpolate data on log plot?

$\endgroup$
  • $\begingroup$ what if you use InterpolationOrder with ListLogPlot like ListLogPlot[Data, Joined -> True, InterpolationOrder -> 3] $\endgroup$ – Sumit Jul 9 '17 at 9:11
  • $\begingroup$ Dear Sumit, thank you for the reply, this gives me a smoother plot, but I want an interpolated function which would look like ListLogPlot[Data, Joined -> True] $\endgroup$ – Wint Jul 9 '17 at 9:28
  • 6
    $\begingroup$ It'll be due to the difference between interpolating in log space or linear space. This'll get you what you want: if = Exp@*Interpolation[{#1, Log[#2]} & @@@ Data, InterpolationOrder -> 1] then LogPlot[if[x], {x, 5, 14}] $\endgroup$ – Quantum_Oli Jul 9 '17 at 9:47
  • $\begingroup$ Quantum_Oli thank you very much!! Please post as an answer and I mark it as solved. :) $\endgroup$ – Wint Jul 9 '17 at 10:02
1
$\begingroup$

[Just noticed this was @Quantum_Oil's idea in a comment above. Probably why I didn't answer before.]

Often one interpolates to avoid transcendental functions, but the OP's objective cannot be achieved with polynomial interpolation. So I assume something like the following, which reproduces ListLogPlot[Data, Joined -> True], is desired:

ClearAll[logIF];
logIF[x_] = 
  Exp[Interpolation[MapAt[Log, Data, {All, 2}], InterpolationOrder -> 1][x]];
LogPlot[logIF[x], {x, 5, 14}]

Mathematica graphics

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.