Choose Language Hide Translation Bar
Highlighted
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 2

Is this possible in JMP?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
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:

and there are lots of additional customizations you could use.

5 REPLIES 5
Highlighted
Staff

## 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
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:

and there are lots of additional customizations you could use.

Highlighted
Level I

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

Excellent, this worked. Thank you.
Highlighted
Staff

## 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
Staff

## 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.