I have established that within one variable A, two subsets appear have a different relation with variable X. Now I'm trying to plot this.
Using 'graph twoway' I manage either 2 scatterplots in one graph or one scatterplot plus linear fit (see code below and graphs attached).
Want I want to achieve is:
1) have one graph, with scatterplots for both subsets, and linear fit lines for each
2) ideally, to have the scatterplots for subsets 1 and 2 just slightly offset (with respect to values of X) so that they do not overlap anymore.
Using 'graph twoway' I manage either 2 scatterplots in one graph or one scatterplot plus linear fit (see code below and graphs attached).
Want I want to achieve is:
1) have one graph, with scatterplots for both subsets, and linear fit lines for each
2) ideally, to have the scatterplots for subsets 1 and 2 just slightly offset (with respect to values of X) so that they do not overlap anymore.
Code:
*scatterplots colorcoded bu subset (graph.gph) graph twoway (scatter A X if subset==1) (scatter A X if subset==2), xtitle(X) ytitle(A) legend(order(2 "A, subset 1" 1 "A, subset 2")) *scatterplot one subset with linear fitted values (graph2.gph) graph twoway (scatter A X if subset==1) (lfit A X if subset==1), xtitle(X) ytitle("A, subset 1") legend(order(1 "A, subset 1" 1 "Lin. fit (A, subset 1"))
Comment