
# File: chap2_figure2_B.py
# Programmer: Anne Dawson
# Date: Saturday 14th August 2010, 17:38 PT
# Python Version: 2.6
# OS: Windows 7

import math
import pylab  # matplotlib

# create the x list data
# arange() is just like range() but allows float numbers
x_list = pylab.arange(-3, 4, 0.1)

# calculate the y list data
y_list = []
for x in x_list:
    y = x**2 - 3
    y_list.append(y)

pylab.title('Chapter 2, Figure 2')
pylab.xlabel("x")
pylab.ylabel("y = x^2 - 3")
pylab.grid(True)


# draw the plot with a blue line 'b' (is default)
# using x,y data from the x_list and y_list
# (these lists can be brought in from other programs)
#
# other drawing styles -->
# 'r' red line, 'g' green line, 'y' yellow line 
# 'ro' red dots as markers, 'r.' smaller red dots, 'r+' red pluses
# 'r--' red dashed line, 'g^' green triangles, 'bs' blue squares
# 'rp' red pentagons, 'r1', 'r2', 'r3', 'r4' well, check out the markers
#
# pylab.plot(x_list, y_list, 'y')
pylab.plot(x_list, y_list, 'g')

# save the plot as a PNG image file (optional)
pylab.savefig('chap2_figure1.png')

# show the pylab plot window
# from the pylab plot window you can zoom the graph,
# drag the graph, change the margins,
# save the graph to pdf and other formats
# from Adobe reader you can select:
# View -> Read Out Loud (speakers on) to speak any text on a pdf.

pylab.show()
