0
$\begingroup$
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

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

1 Answer 1

2
$\begingroup$

Turning comment into answer:

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$ Jun 29, 2018 at 14:53
  • $\begingroup$ 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. $\endgroup$
    – Fraccalo
    Jun 29, 2018 at 14:57
  • $\begingroup$ i see, thank you ~~~~ $\endgroup$ Jun 30, 2018 at 23:38

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.