cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
LokeshPulmo
Level I

How to add Fit Line (Trend Line) at subgroups in a scatter plot.

 

 

How to insert separate Fit Line (Trend Line) for males and females in the same scatter plot. 

 

The scatter plot should have different symbols for males and females.

 

 

With Best Regards,

Lokesh K S,
1 REPLY 1
txnelson
Super User

Re: How to add Fit Line (Trend Line) at subgroups in a scatter plot.

There are a few different platforms that can be used to plot trend lines for different subgroups.

Scatterplot Matrix'

txnelson_0-1636189697324.png

  1. Go to     Graph=>Scatterplot Matrix
  2. Specify the X and Y columns to use
  3. Specify the Group variable to be Sex
  4. Once the graph is open, select Fit Line from the red triangle.
  5. To change the color and the markers, go to the data table 
    1. Select all of the rows for the males
    2. Go to Row State column for one of the selected rows and right click and select the color to use
    3. Right click again, and select the marker to use 
    4. Repeat the above three steps for the females

Graph Builder

txnelson_1-1636190534075.png

  1. Go to    Graph=>Graph Builder
  2. Drag the X column to the X Drop area
  3. Drag the Y column to the Y Drop area
  4. Right Click on the chart and select    Smoother=>Remove
  5. Click on the Fit Line icon txnelson_2-1636190781215.png

     

  6. Drag the Sex column to the Overlay Drop Area
  7. Drag the Sex column to the Color Drop area
  8. In the legend area, right click on each of the lines and change the color and line style to match the colors of the markers

Fit Y by X

txnelson_4-1636191296465.png

 

  1. Go to    Analyze=>Fit Y by X
  2. Select the X and Y columns
  3. In the output display, under the red triangle, select Group By and select the Sex column
  4. Under the red triangle, select    Fit Line
  5. Change the marker and the color of the points as was done in the Scatterplot Matrix, by changing the Row State values for each of the sexes.

 

Jim