package awt;

import stdlib.StdDraw;

public class Plot extends StdDraw{
	
	/**
	 * Plot points (i, a[i]) to standard draw.
	 */
	public void points(double[] a) {
		int n = a.length;
		setXscale(0, n-1);
		setPenRadius(1.0 / (3.0 * n));
		int i;
		for(i=0; i<n; i++)
			point(i, a[i]);
	}

	/**
	 * Plot line segments connecting points (i, a[i]) to standard draw.
	 */
	public void lines(double[] a) {
		int n = a.length;
		setXscale(0, n-1);
		setPenRadius();
		int i;
		for(i=1; i<n; i++) 
			line(i-1, a[i-1], i, a[i]);
	}

	/**
	 * Plot bars from (0, a[i]) to (i, a[i]) to standard draw.
	 */
	public void bars(double[] a) {
		int N = a.length;
		setXscale(0, N-1);
		int i;
		for(i=0; i<N; i++)
			StdDraw.filledRectangle(i, a[i]/2, .25, a[i]/2);
	}
}
