
# File: function_linear_00.py
# Programmer: Anne Dawson
# Date: Sunday 19th September 2010, 18:27 PT
# Python Version: 2.6
# OS: Windows XP
# Textbook: Precalculus - Functions and Graphs, Swokowski & Cole, 11e
# Plotting some coordinates of a linear equation: y = -2x + 7



import pylab  # matplotlib


# create the x list data
# arange() is just like range() but allows float numbers
x_list = pylab.arange(-5, 4) # range is -5 to +4 

# calculate the y list data for y = -2x + 7
y_list = []
for x in x_list:
    y = -1 * 2 * x + 7
    y_list.append(y)

pylab.title('Linear equation:   y = -2x + 7',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, y_list, 'b') # plot with a blue line

pylab.xlim(-10,10)  # 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('function_linear_00.png')
pylab.show()
