Re: Data Plotting Questions
- To: mathgroup at smc.vnet.net
- Subject: [mg25922] Re: [mg25889] Data Plotting Questions
- From: BobHanlon at aol.com
- Date: Tue, 7 Nov 2000 23:05:06 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 11/7/2000 4:29:12 AM, bobmarley4u2c at my-deja.com writes:
>If I have a data, and I found the best fit polynomials. Now I want to
>graph the polynomial and the data points on the same graph. How would I
>do that in Mathematica?
>
Needs["Graphics`Graphics`"];
Clear[f, x];
f[x_] := x^3 - 5x^2 - x - 6;
xmin = -4; xmax = 7; nbrPts = 10;
data = Table[{x = ((xmax - xmin)*Random[] + xmin),
f[x] + 20(Random[] - .5)}, {nbrPts}];
Clear[x];
ft = Fit[data, {1, x, x^2, x^3}, x]
DisplayTogether[
ListPlot[data, PlotStyle -> {AbsolutePointSize[4], RGBColor[1, 0, 0]}],
Plot[ft, {x, xmin, xmax}, PlotStyle -> RGBColor[0, 0, 1]]];
Bob Hanlon