graphing y=mx+b

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
Two part question and TIA

1) How can I graph 2 lines (both of the form y=mx+b, where I have both m's and both b's) on the SAME GRAPH?

and

2) How can I (or should I say can I) put this graph in a User Form?

Gene, "The Mortgage Man", Klein
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I don't understand the question.
I assume you have 2 columns of data to chart:
Column A contains values of mx+b and column B contains values of y. Sounds like a standard plot task for the chart wizard.
How do you get two lines from this??
 
Upvote 0
I have 4 values. Lets call them m1, b1, m2, b2. m1 and b1 define one line (with b1 being the y intercept of the first line and m1 being the slope of the first line). m2 and b2 define the second line (with similar meanings for m2 and b2). I want to plot both lines on the same graph. Then I want to put this graph in a userform.

Gene, "The Mortgage Man", Klein
 
Upvote 0
bump - nobody knows (or is it just everyone is away for labor day)?

Gene, "The Mortgage Man", Klein
 
Upvote 0
Upvote 0
To plot a straight line you need 2 points (x1,y1) and (x2,y2).

Assuming you want to show the the intersection of 2 lines, first calculate where they intersect. Let this be (Xi, Yi). To find the values, set the y's equal and solve for x. So, with a little algebra, you'll get

Xi=(b2-b1)/(m1-m2) and Yi=m1*(b2-b1)/(m1-m2)+b1...I think

Now, put 2 points for each line in the layout (*)
Code:
x11 y11    x21 y21
x12 y12    x22 y22

Select the data in the first 2 columns and cick the chart wizard. In step 1 create a XY Scatter chart (for the subtype select one with connecting lines). In step 2 make sure XL knows the data are in columns and that column 1 contains X values.

Once the chart is done, select and drag the second set on to the chart. In the dialog box that pops up make sure XL knows the data are in columns and the 1st column contains X values.

(*) As a refinement, you may want to include the intersection point. Suppose (Xi, Yi) is in the first quadrant (both x and y are positive). Then, you may want to plot
Code:
0     b1       0     b2
Xi    Yi       Xi    Yi
2*Xi  Y12      2*Xi  Y22

Edit: As far as Q2 goes, there is no elegant solution. You have already been referred to both approaches that I know (the one documented by John Walkenbach and the other from Stephen Bullen).
Two part question and TIA

1) How can I graph 2 lines (both of the form y=mx+b, where I have both m's and both b's) on the SAME GRAPH?

and

2) How can I (or should I say can I) put this graph in a User Form?

Gene, "The Mortgage Man", Klein
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,288
Members
448,563
Latest member
MushtaqAli

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top