# Plotting line fit

data = {{4, 4}, {4, 25}, {25, 63}, {63, 147}, {147, 285}, {285,
361}, {361, 405}, {405, 471}, {471, 420}, {420, 430}, {430,
420}, {420, 475}, {475, 435}, {435, 480}};


I have data like above , data Pn as x and P(n+1) as y

I am using Fit to make the plot, but the plot only shown dots not line:

line = Fit[data, {1, x}, x]
parabola = Fit[data, {1, x, x^2}, x]


im trying to compare the linear and quadratic data on my cases

• Doesn't Show[ListPlot[data, PlotStyle -> Red], Plot[{line, parabola}, {x, 0, 500}]] help you? Jun 29, 2018 at 14:45

Try:

Show[
ListPlot[data, PlotStyle -> Red]
,Plot[{line, parabola}, {x, 0, 500}]
]


Btw, I quickly checked and this code can be found in the documentation, I suggest you to look into that when you have a problem as it helps a lot, in particular if you have just started programming in Mathematica.

• Thanks its work, but i already try it before with Show[ListPlot[Data, PlotStyle -> Red], Plot[{line, parabola}, {x, 0, 5}]] but it wasn't work , can you tell me why? Jun 29, 2018 at 14:53
• The problem is the range of the plot: in your code you copy-pasted the definition from the documentation, but you didn't change the range. Indeed, you are plotting values from 0 to 5, while your data span from 4 to 435. That's why you need to plot the functions over a much larger range (in my code, I used 0 to 500 as you can see). Hope the explanation makes sense, feel free to ask if you have any doubt about it. Jun 29, 2018 at 14:57
• i see, thank you ~~~~ Jun 30, 2018 at 23:38