Jamgreen
Jamgreen

Reputation: 11039

Draw lines between points in Maple

In Maple I have two lists

n:=10:
A:=[seq(i, i=1..n)];
B:=[10, 25, 43, 63, 83, 92, 99, 101, 101, 96];

I want to plot the values

plot([seq([A[i], B[i]], i=1..n)]);

It works, but the lines between the points are not curved.

If I draw a line using these points in Excel, it will interpolate the values between the points and draw a nice and smooth curve.

This must also be possible to do in Maple, but I cannot find the options to do this.

If I look in options in the documentation http://www.maplesoft.com/support/help/maple/view.aspx?path=plot%2foptions, I see that I probably need to use the argument style. The doc says The styles line, polygon, and polygonoutline all draw curves by interpolating between the sample points, but it doesn't draw the curves even if I use style=line.

Upvotes: 0

Views: 658

Answers (1)

Carl Love
Carl Love

Reputation: 1471

There's a way to do it (below), but it's not an option to plot. The command plot uses linear interpolation. Usually the number of points being plotted is large enough that this is sufficient. To get a higher-order interpolation, use CurveFitting:-Spline, like this:

plot([CurveFitting:-Spline(A,B,x), zip(`[]`,A,B)], x= 1..10, style= [line, point]);

Notice that there are separate sections of the above command for plotting the curve and plotting the points themselves.

Upvotes: 1

Related Questions