Show a Movable Line on a Graph

You can add an unfitted, movable line to any graph that has numeric attributes on both the horizontal and vertical axes (both the X and Y axes).

  1. Select the graph.
  2. Click the ruler icon in the right corner of the Graph window.
  3. Check Movable Line, as shown below. You can then click and drag the line so that it goes through the points on your graph. Note that the equation used to produce the line also appears on the graph in a yellow box (you can drag the box to a new position in the graph if you want to). The equation will change as you drag the line.
  4. If you decide that your line should always pass through the origin (0, 0) on the graph, click on the ruler icon in the inspector panel to the right of the graph, and choose Intercept Locked from the menu, as shown here: 

Dragging the line by its middle keeps the slope but changes the intercept (translates the line) (this will not work if the intercept is locked). Dragging by either end changes the slope (rotates the line). The cursor you get when you hover over the line changes to tell you which kind of drag you’re about to perform (arrows pointing straight up and down for translating the line vs. curved arrows for roating the line).

Also, try checking the box for "Squares of Residuals" in the ruler/Measure menu. This will add a visual representation of the squares of residuals to your graph, as well as the exact sum of squares value in the yellow highlighted box on the graph. As you drag/move the line around, the squares of residuals (and the sum of squares value) will change. Try dragging the line to get the best fit to the data points and to minimize the sum of squares, manually performing least squares regression (see 2nd gif below) (least squares regression can also be done automatically in CODAP--see here).

  • Note: To remove a movable line, uncheck Movable Line from the Ruler menu.
Was this Article Useful? 

Comments

Is there a way to access the current slope and intercept of the movable line to do computations with them? I am hoping to use them in a formula for a computed column.

Unfortunately, there is no way to access the slope and intercept of a movable line in a formula.

Is there a way to get the slope and intercept of the movable line as variables, almost like slider variable values, to use in computing a formula for a computed column?

Here’s an idea. Create two sliders, let’s say named m and b. Now, in the scatterplot, using the Ruler menu, choose Plotted Function. Click in the function area at the top of the plot and enter m*x+b. (Or, if you like, you can use the name of the attribute on the x axis; e.g. m*Height+b). When you press Apply you’ll see your line (assuming your axis bounds permit). The two sliders will control the line and you can use them in formulas elsewhere.

I wanted to be able to fix a point on the line when I changed the slope, for example fixing a candidate regression line at the mean-mean point. I think I have a working model of how the line works. The middle handle translates up and down as advertised. Grabbing an end handle rotates the line, but watch where you take your cursor; what ever point pt your cursor stops at, using the other end handle will rotate around that point pt. This is why sometimes the graph rotates around an end handle and sometimes not, it is all according if the end handle from the last drag could follow and stop where your cursor does. I have also notice that a drag off the window ends up in a rotation point at the boundary.
Can I get verification that (1) I am being clear, and if so, (2) this is correct. It would be really worthwhile (imo) to make this feature clear in the help. Or more embarrassingly, this is explained and I missed it. Thanks!

Your very clear explanation of what you have discovered is completely correct. If you wouldn’t mind posting your question in the CODAP Help forum (https://codap.concord.org/forums/forum/test/) then at least we would have your documentation of how dragging the movable line works ;)

Add new comment

Comments are closed for the CODAP Help site. If you have a question or problem, please post on the CODAP Help Forum instead. Thank you.