squareplot - [email protected] Updated docstring...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import matplotlib.pyplot as plt import numpy as np import square def squareplot(lo, hi, n, savename=False): ''' Plots the squares of n points evenly distributed from lo to hi, inclusive. Parameters ---------- lo : scalar The low end of the range. hi : scalar The high end of the range. n : int The number of points in the range. Returns ------- none Examples -------- >>> import matplotlib.pyplot as plt >>> import squareplot as sp >>> sp.squareplot(0, 8, 5) >>> plt.show() Revisions --------- 2007-09-11 0.1 [email protected] Initial version 2007-11-23 0.2 [email protected] Removed (misplaced) figure write 2008-11-01 0.3 [email protected] Updated docstring 2009-09-16 0.4
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: [email protected] Updated docstring arange->linspace, code cleanup ''' # get numbers to square and square them x, step = np.linspace(lo, hi, n, retstep=True) y = square.square(x) # plot them plt.plot(x, y, 'o') # pad the axes (this block optional for hw3, just demos axis padding) xaxpad = step/2 yaxpad = square.square(np.array([x.min(), x.min() + step / 2])) yaxpad = yaxpad[1] - yaxpad[0] plt.axis([x.min() - xaxpad, x.max() + xaxpad, y.min() - yaxpad, y.max() + yaxpad]) # words plt.xlabel('Input') plt.ylabel('Output') plt.title('Square Function') # save file if savename: plt.savefig(savename) return...
View Full Document

This note was uploaded on 11/09/2009 for the course AST 4762 taught by Professor Harrington during the Fall '09 term at University of Central Florida.

Page1 / 2

squareplot - [email protected] Updated docstring...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online