- Setting win.setCoords(0,0,x,y) is what allows us to follow a coordinate system just like in the first quadrant of the classic graph interface.
- This project required gathering information only through the user clicking on the screen, and clicking 'Done' when he/she finishes. I've accomplished this with a very cool technique:
- While True, will continue through a infinite loop, and if the user clicks within the premise of the defined rectangles (in green), the while loop will 'break'. In any other case, each point should be conveniently drawn for the user as well as recorded for the regression line.
- Next, I've gone through a series of for loops that computed the sum of the recorded x and y values.
- One particular loop that I've learned was one that found the sum of the product of x(y).
- To do this, I've set one loop that follows through the length of either range x or y, and set to multiply the recorded values of x and y through slicing.
- Finally after formulating the slope of the line, and defining it's y-intercept, the challenge was to plot a line that extended through out the window, as shown below.
- The first point was simple, as it is merely the y int. In the second, I knew I had to extend x to the range of my defined window,(set through GraphWin); it's y-cord was based reletively on the ratio of slope 'm'(window) + P1
Tuesday, March 4, 2014
Graphing the Line of Best Fit
There was a lot of information covered throughout this code. Here are some of the things I've learned:
Labels:
Python
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment