def plotLines(a): """Plot the elements of array a as line end-points.""" n = len(a) stddraw.setXscale(-1, n) stddraw.setPenRadius(0.0) for i in range(1, n): stddraw.line(i - 1, a[i - 1], i, a[i])
def plotPoints(a): """Plot the elements of array a as points.""" n = len(a) stddraw.setXscale(-1, n) stddraw.setPenRadius(1.0 / (3.0 * n)) for i in range(n): stddraw.point(i, a[i])
def plotBars(a): """ Plot the elements of array a as bars. """ n = len(a) stddraw.setXscale(-1, n) for i in range(n): stddraw.filledRectangle(i - 0.25, 0.0, 0.5, a[i])