Final project - Scatter plot with different if qualifier for each variable

Re: Final project - Scatter plot with different if qualifier for each variable

by Eduardo Rodriguez Almaraz -
Number of replies: 0

Hi,

I think we would need to take a look at your data. But, I assume that you have your "time point" variable coded as 1,2,3,4,etc (or something similar). after you define your "scatter" line of code you can use the  "by" statement to create a plot similar to the above. For example:


webuse nhanes

scatter height weight, by(bmi_cat) // I recoded bmi cat in 3 groups and you have a plot like this


You should be able to combine the layering options provided in the previous response with the "by" option to get a plot that looks like this:

scatter weight height if race == 1 & race ==1, mcolor(green by (bmi_cat) || scatter weight height if race ==2 & sex ==2, mcolor(red)  by(bmi_cat)



The issue is if you have dozens of time points it will create dozens of graphs so I would suggest to create another variable that contains only the timepoints that you want so when you apply the "by" option creates only a few plots.


I hope this helps