Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
JonathanL
Level I

Is it possible to display multiple fit lines of different degrees in a single plot?

I would like to display both linear and quadratic fit lines in the same plot. Essentially a combination of the two plots I've attached to this post.

graph 1graph 1graph 2graph 2

Is this possible in JMP?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ian_jmp
Staff

Re: Is it possible to display multiple fit lines of different degrees in a single plot?

Given your intention, it might be better to look at 'Analyze > Fit Y By X'.

 

This script:


dt = Open("$SAMPLE_DATA/Big Class.jmp");

biv = dt << Bivariate(
				Y( :height ),
				X( :weight ),
				GroupBy( :sex ),
				FitLine(),
				FitPolynomial(2)
				)

will produce output like this:

Screenshot 2020-05-22 at 16.59.24.png

and there are lots of additional customizations you could use.

View solution in original post

5 REPLIES 5
Highlighted

Re: Is it possible to display multiple fit lines of different degrees in a single plot?

I don't think you can do this in Graph Builder, but you can in Fit Y by X.

 

It looks like you may have an overlay variable, just be sure to use the Fit Y by X "Group By" command before fitting the lines and the quadratic polynomials.

Dan Obermiller
Highlighted
ian_jmp
Staff

Re: Is it possible to display multiple fit lines of different degrees in a single plot?

Given your intention, it might be better to look at 'Analyze > Fit Y By X'.

 

This script:


dt = Open("$SAMPLE_DATA/Big Class.jmp");

biv = dt << Bivariate(
				Y( :height ),
				X( :weight ),
				GroupBy( :sex ),
				FitLine(),
				FitPolynomial(2)
				)

will produce output like this:

Screenshot 2020-05-22 at 16.59.24.png

and there are lots of additional customizations you could use.

View solution in original post

Highlighted
JonathanL
Level I

Re: Is it possible to display multiple fit lines of different degrees in a single plot?

Excellent, this worked. Thank you.
Highlighted

Re: Is it possible to display multiple fit lines of different degrees in a single plot?

I agree with @Dan_Obermiller and @ian_jmp but if you really need to use Graph Builder, then the approach is to first fit the models separately and save each one of them as column formula. Then add these columns in the Y drop zone of Graph Builder. Now change the rendering element to Formula.

Learn it once, use it forever!
Highlighted
julian
Community Manager Community Manager

Re: Is it possible to display multiple fit lines of different degrees in a single plot?

Hi @JonathanL,

This can be done in Graph Builder, if you would prefer to do it there. If you would like to display a second line element using a different degree, you'll need to add that second element, either by holding the shift key and clicking the line of fit element, or dragging the line of fit element into the graph after you've already selected it. Then, you can change the degree for this second line of fit element. Like every other element, variables in other roles are respected unless disabled, so if you have a variable in the Overlay role, both of these line elements will display lines of fit separately for the levels of the Overlay variable.

 

Dual.gif

 

 

@julian 

Article Labels

    There are no labels assigned to this post.