
# File: quad_function08B.py
# Programmer: Anne Dawson
# Date: Thursday 7th October 2010, 11:33 PT
# Python Version: 2.6
# OS: Windows 7 / XP
# Textbook: Precalculus - Functions and Graphs, Swokowski & Cole, 11e
# Page: 184, Ex 8 - quadratic function in form y = 5x^2 + 20x + 17
# Answer: y = 5(x + 2)^2 -3

import pylab  # matplotlib

# create the x list data
# arange() is just like range() but allows float numbers
x_list = pylab.arange(-6, 7, 0.1) # range is -10 to +5 in steps 0.1


# calculate the y list data
y_list = []
for x in x_list:
    y = 5 * (x + 2)**2 - 3
    y_list.append(y)

pylab.title('Parabola: y = 5(x + 2)^2 -3  (Answer - Page 184, #8)',fontsize=16, color='b')
pylab.xlabel("x",fontsize=18, color='r')
pylab.ylabel("y",fontsize=18, color='r')

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


# 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, 'b') # plot with a blue line
pylab.xlim(-4,1)  # this line must be placed AFTER the plot line
pylab.ylim(-4,10) # this line must be placed AFTER the plot line
# save the plot as a PNG image file (optional)
pylab.savefig('quad_function08B.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()
