
# File: circle_unit_01.py
# Programmer: Anne Dawson
# Date: Sunday 22nd August 2010, 12:38 PT
# Python Version: 2.6
# OS: Windows 7
# Textbook: Precalculus - Functions and Graphs, Swokowski & Cole, 11e
# Page: 110

# unit circle, when radius = 1


import pylab  # matplotlib


# create the x list data
# arange() is just like range() but allows float numbers
x_list = pylab.arange(-1, 1, 0.0005) # range is -1 to +1 in steps 0.0005

# calculate the y1 list data for y = plus sqrt(1 - x^2)
y1_list = []
for x in x_list:
    y = pylab.sqrt(1 - x**2)
    y1_list.append(y)

# calculate the y2 list data for y =  minus pylab.sqrt(81 - x**2)
y2_list = []
for x in x_list:
    y = -1 * pylab.sqrt(1 - x**2)
    y2_list.append(y)
 

pylab.title('The Unit Circle: y = +/- square root of 1 - x squared',fontsize=13, color='black')
pylab.xlabel("x",fontsize=18, color='black')
pylab.ylabel("y",fontsize=18, color='black')
pylab.grid(True)
pylab.axhline(0, color='black', lw=2) # axis horizontal line at y = 0, line width 2
pylab.axvline(0, color='k', lw=2) # axis vertical line at x = 0, line width 2, color black
pylab.plot(x_list, y1_list, 'b') # plot with a blue line
pylab.plot(x_list, y2_list, 'r') # plot with a red line
pylab.xlim(-2,2)  # this line must be placed AFTER the plot line
pylab.ylim(-2,2) # this line must be placed AFTER the plot line

# save the plot as a PNG image file (optional)
pylab.savefig('circle_unit_01.png')
pylab.show()
