# Polygonal paths: polygonplot ligne_polygonale linear_interpolate listplot plotlist

### 8.2.3 Polygonal paths: polygonplot ligne_polygonale linear_interpolate listplot plotlist

The polygonplot command draws a polygonal path through given points.
polygonscatterplot is a synonym for polygonplot.

- polygonplot takes one mandatory argument and one optional argument:
  - Optionally, xcoords, a list of x-coordinates. By default, the x-coordinates will be a list of integers starting at 0.
  - ycoords, a list of y-coordinates.
  You can combine two arguments into a matrix with two columns (each list becomes a column of the matrix).
- polygonplot(⟨xcoords,⟩ ycoords) draws the polygonal path through the given points, from left to right (so the points are automatically ordered by increasing x-coordinate).

#### Examples.

- Input:
  polygonplot([0,1,2,3,4],[0,1,4,9,16])
  or:
  polygonplot([[0,0],[1,1],[2,4],[3,9],[4,16]])
  or:
  polygonplot([[2,4],[0,0],[3,9],[1,1],[4,16]])
  Output:
- Input:
  polygonplot([0,1,4,9,16])
  Output:

The listplot draws a polygonal path, but in an order determined by you.
plotlist is a synonym for listplot.

- plotlist takes one argument:
  L, a list of points or a list of numbers (which will be taken as y-coordinates, with the x-coordinates being the integers starting at 0).
- plotlist(L) draws a polygonal path through the points in the order given by the list.

Unlike polygonplot, the listplot command can’t be given two lists of numbers as arguments.

#### Examples.

- Input:
  listplot([[2,4],[0,0],[3,9],[1,1],[4,16]])
  Output:
- Input:
  listplot([0,1,4,9,16])
  Output:

If you want to get coordinates on the polygonal path, you can use the The linear_interpolate command will find coordinates on the polygonal path.

- linear_interpolate takes four arguments:
  - M, 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.
  - xstep, the step size that you want.
  The values of xmin and xmax must be between the smallest and largest x-coordinates of the points.
- linear_interpolate(M,xmin,xmax,xstep) returns 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.

#### Example.

Input:

linear_interpolate([[1,2,6,9],[3,4,6,12]],2,7,1)

Output:

⎡
⎢
⎣

2.0 | 3.0 | 4.0 | 5.0 | 6.0 | 7.0
4.0 | 4.5 | 5.0 | 5.5 | 6.0 | 8.0

⎤
⎥
⎦