
# File: poly_functs_02.py
# Programmer: Anne Dawson
# Date: Tuesday 19th October 2010, 8:34 PT
# Python Version: 2.6
# OS: Windows 7
# Textbook: Precalculus - Functions and Graphs, Swokowski & Cole, 11e
# Page: 211


import pylab  # matplotlib


# create the x list data
# arange() is just like range() but allows float numbers
x_list = pylab.arange(-4, 4, 0.1) # range is -4 to +4 in steps 0.1
# x_list = pylab.arange(-4, 4) # range is -4 to +4 in steps1 (default)

# calculate the y list data
y_list = []
for x in x_list:
    y = x**3 + x**2 - 4*x - 4
    y_list.append(y)




pylab.title('f(x) =   y = x^3 + x^2 -4x - 4',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='black', lw=2) # axis vertical line at x = 0, line width 2
pylab.plot(x_list, y_list, 'b') # plot with a blue line

pylab.xlim(-6,6)  # this line must be placed AFTER the plot line
pylab.ylim(-10,10) # this line must be placed AFTER the plot line


# save the plot as a PNG image file (optional)
pylab.savefig('poly_functs_02.png')
pylab.show()
