squareplot - [email protected] Updated docstring...

Info icon This 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
Image of page 1

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

View Full Document Right Arrow Icon
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern