You can draw a polygonal path with either polygonplot or listplot.
Given a list of points (a two-column matrix) or two lists (the x coordinates and the y-coordinates), the polygonplot (or polygonscatterplot) command will draw the polygonal path through the points, from left to right (so the points are automatically ordered by increasing x-coordinates). If you enter
or
or even
you will get
If you give polygonplot a single list of numbers, then they will be taken to be the y-coordinates and the x-coordinates will be assumed to be integers starting at 0. If you enter
If you want to get coordinates on the polygonal path, you can use the linear_interpolate command. This command takes four arguments; a two-row matrix consisting of the x-coordinates and the y-coordinates, xmin, the minimum value of x that you are interested in, xmax, the maximum value of x, and xstep, the step size you want. (The values of xmin and xmax must be between the smallest and largest x-coordinates of the points.) You will get a matrix with two rows, the first row will be [xmin, xmin+xstep, xmin+2xstep,...,xmax] and the second row will be the corresponding y-coordinates of the points on the polygonal path. For example, if you enter
you will get
If you want to draw a polygonal path through points in an order determined by you, you can use the listplot (or plotlist) command. If you give listplot a list of points, then you will get a polygonal path through the points in the order given by the list. If you enter
you will get
As with polygonplot, if you give listplot a single list of numbers, then they will be taken to be the y-coordinates and the x-coordinates will be assumed to be integers starting at 0. If you enter
you will get the same graph that you got with polygonplot. However, unlike polygonplot, the listplot command can’t be given two lists of numbers as arguments.