Task

Plot a function represented as     x,  y     numerical arrays.

Post the resulting image for the following input arrays (taken from Python's Example section on Time a function):

      x = {0,   1,    2,    3,    4,    5,     6,     7,     8,     9};
      y = {2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0};

This task is intended as a subtask for Measure relative performance of sorting algorithms implementations.




x[] = [ 0 1 2 3 4 5 6 7 8 9 ]
y[] = [ 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0 ]
# 
clear
linewidth 0.5
move 10 3
line 10 95
line 95 95
textsize 3
n = len x[]
m = 0
for i range n
  m = higher y[i] m
.
linewidth 0.1
sty = m div 9
for i range 10
  move 2 94 - i * 10
  text i * sty
  move 10 95 - i * 10
  line 95 95 - i * 10
.
stx = x[n - 1] div 9
for i range 10
  move i * 9 + 10 96.5
  text i * stx
  move i * 9 + 10 95
  line i * 9 + 10 3
.
color 900
linewidth 0.5
for i range n
  x = x[i] * 9 / stx + 10
  y = 100 - (y[i] / sty * 10 + 5)
  if i = 0
    move x y
  else
    line x y
  .
.