Hi everyone,
I am so close to figuring this out, yet feel so far. I would like to reproduce the following plot which has different colors depending on the quadrant (soc_graph_quad) that a point falls into:

Unfortunately, the labels consistently overlap, so I would like to plot each point individually so that I could manually move them in the graph editor. I need to do this many times for different yet related domains, so I do not want to create a "position" variable that changes the position of the label for individual points.
This is my data:
This is what I have tried so far, but it only results in one point getting plotted 16 times:
I've seen Andrew Musau's code #3 here: https://www.statalist.org/forums/for...urs-in-pcspike and #2 here: https://www.statalist.org/forums/for...-a-observation that creates a local command macro to loop through categories, but I can't seem to create something similar to loop through all 16 points and the conditional quadrant coloring logic.
Thank you,
Ashleigh
I am so close to figuring this out, yet feel so far. I would like to reproduce the following plot which has different colors depending on the quadrant (soc_graph_quad) that a point falls into:
Unfortunately, the labels consistently overlap, so I would like to plot each point individually so that I could manually move them in the graph editor. I need to do this many times for different yet related domains, so I do not want to create a "position" variable that changes the position of the label for individual points.
This is my data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(socwb_health socwb_relevance soc_graph_quad socwb_labels) -.3139982 1.6270845 4 1 1.949235 1.0825317 1 2 .14476526 1.125838 1 3 -.4975036 1.720457 4 4 -.1916613 .9536769 4 5 -.7421775 .558949 4 6 1.0622922 .9521463 1 7 -.25282976 .6484658 4 8 .4811918 1.1118306 1 9 .05301256 .7214679 1 10 -.43633515 .6277263 4 11 -1.2621094 .4262436 4 12 .8482026 1.477142 1 13 1.1540449 .8362689 1 14 -1.996131 1.4378642 4 15 -3.2500846 .023809524 4 16 end label values socwb_relevance socwb label values socwb_labels socwb label def socwb 1 "Amount of contact with others", modify label def socwb 2 "People who are kind and respectful", modify label def socwb 3 "Feeling appreciated by others", modify label def socwb 4 "Sense of belonging", modify label def socwb 5 "Freedom to express my opinion", modify label def socwb 6 "People who help me feel calm", modify label def socwb 7 "People who accept me", modify label def socwb 8 "People who are accessible", modify label def socwb 9 "People who listen well", modify label def socwb 10 "Emotional support", modify label def socwb 11 "Practical support", modify label def socwb 12 "Support in trying new things", modify label def socwb 13 "Close friendships", modify label def socwb 14 "Caring for others", modify label def socwb 15 "Coping with relational conflict or challenges", modify label def socwb 16 "Other", modify label values soc_graph_quad graph_quad label def graph_quad 1 "Celebrate", modify label def graph_quad 4 "Prioritize", modify
This is what I have tried so far, but it only results in one point getting plotted 16 times:
Code:
separate socwb_relevance, by(socwb_labels) separate socwb_health, by(socwb_labels) separate socwb_labels, by(socwb_labels) forvalues i=1/16{ scatter socwb_relevance_all_`i' socwb_health_all_`i' if soc_graph_quad==1, mcolor("0 204 102") msize(2) mlabel(socwb_labels`i') ||scatter socwb_relevance_all_`i' socwb_health_all_`i' if soc_graph_quad==2, mcolor("0 154 193") msize(2) mlabel(socwb_labels`i')|| scatter socwb_relevance_all_`i' socwb_health_all_`i' if soc_graph_quad==3, mcolor("255 177 0") msize(2) mlabel(socwb_labels`i')|| scatter socwb_relevance_all_`i' socwb_health_all_`i' if soc_graph_quad==4, mcolor("235 0 83") msize(2) mlabel(socwb_labels`i') legend(col(4)) ytitle(Importance) xtitle(Health) yline(0, lpattern(dash) lcolor(black%90)) ylabel(-3(1)3) yscale(range(-1 1)) xline(0, lpattern(dash) lcolor(black%90)) xlabel(-3(1)3) xscale(range(-.5 .5)) title(Social Wellbeing) graphregion(fcolor("239 242 251")) plotregion(fcolor(white)) scheme(s1color) mlabcolor(black) mlabsize(vsmall) legend(order(1 "Celebrate" 2 "Maintain" 3 "Review" 4 "Prioritize")) }
Thank you,
Ashleigh
Comment