Hello,
I am working on a scatter plot in Stata and need some guidance on how to achieve the following customizations:
graph twoway /// (scatter `DepVar'_`change1'_* `xvar'_`change3', sort msymbol(O) msize(small) mlab(`prof') mlabc(black) mlabpos(12) mcolor()) /// (scatter `DepVar'_hat_`change1'_* `xvar'_`change3', sort msymbol(+) msize(small) mlab(`prof') mlabc(black) mlabpos(12)) /// (qfit hat_`DepVar'_`change1' `xvar'_`change3', lcolor("200 0 0")) /// (qfit `DepVar'_`change1' `xvar'_`change3', lcolor("0 200 0") lpattern(dash)) /// and dashed , xt(`: variable label `xvar'_`change3' ', margin(medium) size(small)) /// xsc(noextend noline) xlab(, nogrid) /// yt(`: variable label `DepVar'_`change1' ', size(small)) /// yline(0, lpattern(dash) lcolor(black)) /// ysc(noextend titlegap(1)) /// legend(pos(7) col(4) order(1 "2. Craftsmen, tradesmen and business owners" 2 "3. Executives and higher intellectual professions" 3 "4. Intermediate professions" 4 "5. Employees" 5 "6. Workmen" 6 "Quadratic fit: DepVar_change1_hat" 7 "Quadratic fit: DepVar_change1") size(vsmall))
Any advice or examples of similar implementations would be greatly appreciated!
Thank you!
I am working on a scatter plot in Stata and need some guidance on how to achieve the following customizations:
- Different Markers for Different Data parts: I have two parts in my data, DepVar_hat_change1_* and DepVar_change1_*. I would like to use different marker shapes for each part. For example, circles (O) for DepVar_hat_change1_* and plus signs (+) for DepVar_change1_*.
- Consistent Colors for Matching Levels Across Data Sets: Each of these sets is further divided into levels (e.g., DepVar_hat_change1_1, DepVar_hat_change1_2, ..., DepVar_change1_1, DepVar_change1_2, ...). I want to use the same color for matching levels across the two sets (e.g., DepVar_hat_change1_1 and DepVar_change1_1 should have the same color).
- Legends: I would like to have two separate legends in my graph:
- One for colors, indicating the profession or category each color represents.
- Another for marker shapes, indicating the part of data each shape represents (e.g., O for DepVar_hat_change1 and x for DepVar_change1_*).
graph twoway /// (scatter `DepVar'_`change1'_* `xvar'_`change3', sort msymbol(O) msize(small) mlab(`prof') mlabc(black) mlabpos(12) mcolor()) /// (scatter `DepVar'_hat_`change1'_* `xvar'_`change3', sort msymbol(+) msize(small) mlab(`prof') mlabc(black) mlabpos(12)) /// (qfit hat_`DepVar'_`change1' `xvar'_`change3', lcolor("200 0 0")) /// (qfit `DepVar'_`change1' `xvar'_`change3', lcolor("0 200 0") lpattern(dash)) /// and dashed , xt(`: variable label `xvar'_`change3' ', margin(medium) size(small)) /// xsc(noextend noline) xlab(, nogrid) /// yt(`: variable label `DepVar'_`change1' ', size(small)) /// yline(0, lpattern(dash) lcolor(black)) /// ysc(noextend titlegap(1)) /// legend(pos(7) col(4) order(1 "2. Craftsmen, tradesmen and business owners" 2 "3. Executives and higher intellectual professions" 3 "4. Intermediate professions" 4 "5. Employees" 5 "6. Workmen" 6 "Quadratic fit: DepVar_change1_hat" 7 "Quadratic fit: DepVar_change1") size(vsmall))
Any advice or examples of similar implementations would be greatly appreciated!
Thank you!
Comment