Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Let's say I have some data generated by anything. For practical sake, let's say I was able to generate a sequence of numbers through a recursion and I listed them out through a table of numbers.

F[1] = 1;
F[n_] := 3*F[n - 1]
H = Table[F[n], {n, 1, 10}]

Now I set the table of values to a variable 'w'


Here I am plotting the data.

What I want to do now is to "fit" a curve that connects all those points. I just want to see the fitted curve on the plot together the data points. I don't even need (or want to) see the equation that best fits the data.

I tried using NonlinearModel and Fit, neither works well for me. The recursion is just an example. I could of course product new data from something else

share|improve this question
The simplest fit is linear interpolation between data points. And that is done by using the following magical incantation: ListPlot[H, Joined -> True]. Do you want anything fancier that this? If so, could you describe it in more detail? – Jens Mar 29 '13 at 4:49
add the option Joined->True and possibly PlotMarkers->Automatic to ListPlot – acl Mar 29 '13 at 5:05
Do you have information on what this plot is to be used for, i.e. what inferences are to be drawn from it – image_doctor Mar 29 '13 at 7:14
Nope, none at all. – Hawk Mar 29 '13 at 19:11

3 Answers 3

up vote 1 down vote accepted

If you just want to see the plot:

ListPlot[H, Mesh -> Full, Joined -> True, PlotRange -> All, InterpolationOrder -> 2]

Mathematica graphics

share|improve this answer
What does the 'order' do? – Hawk Mar 29 '13 at 6:12
@jak It smooths out the curve. Try with values from 0 to 3 – belisarius is forth Mar 29 '13 at 6:16
So I am guessing the higher the value, the better? – Hawk Mar 29 '13 at 6:21
@jak why don't you position your cursor on that keyword and press F1? You'll get your answer right away... – Sjoerd C. de Vries Mar 30 '13 at 14:41
It's interesting, when I make an recursion. If I set the InterpolationOrder greater than 2, my recurison starts back at $-1$ instead of 0 – Hawk Apr 6 '13 at 5:57

My best guess as to what you really want is Interpolation:

F[1] = 1;
F[n_] := 3*F[n - 1]
H = Table[F[n], {n, 1, 10}];

f = Interpolation[H]


Plot[f[x], {x, 1, 10}]


share|improve this answer
I am getting "InterpolatingFunction::dmval: Input value {0.000204286} lies outside the range of data in the interpolating function. Extrapolation will be used. >>" – Hawk Mar 29 '13 at 5:25
@jak An InterpolatingFunction only matches the data its given and won't provide an accurate fit/prediction at values outside of the limits of the data. Here those limits are 1 and 10 as H is a list of 10 numbers (not x-y pairs) so Mma assigns an x-coord of 1,2,3... to each y value. When you try plot beyond the limits (as at $x\simeq0$ above) Mma warns that you're working outside of the 'safe' domain of f and that the results at these points may not be trustworthy. Often plots of an InterpolationFunction far from its 'safe' domain can look very strange compared to the data its based on – fizzics Mar 29 '13 at 10:36

You just need to plot the the power function:

Show[Plot[3^(n - 1), {n, 1, 10}], ListPlot[H]]


share|improve this answer
My understanding was that the data aren't necessarily given by a known function... – Jens Mar 29 '13 at 5:02
@Jens, that's exactly what I mean. I just made up this example. – Hawk Mar 29 '13 at 5:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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