Hi all, moderately new Stata user here using Version 15.1.
I have two groups (male and female) to be different colors on a two way rcap scatter plot (code attached below), but I cannot seem to get that to work. Males are coded as 1 and females as 0, and I need them on the same panel (not two separate panels), so I can't do by(male1female0). Every time I try and change the color in the code by using mcolor(blue) for example, it changes all of them. I have the data in rows, with each row representing 1 age and sex category (so 12 lines in total, since there are 6 age groups and 2 sexes). I created an "agecatjitter" variable, so for males it's slightly right of the marker, and for females it's slightly left of the marker.
Here's my code:
label define agecat 1 "12-14" 2 "14-16" 3 "16-18" 4 "18-20" 5 "20-22" 6 "Over 22"
label values agecat agecat
label define male1fe0 0 "Female" 1 "Male"
label values male1fe0 male1fe0
gen agecatjitter = agecat + 0.20 if male1fe0 == 1
replace agecatjitter = agecat - 0.20 if male1fe0 == 0
twoway rcap upper lower agecatjitter, lstyle(ci) || scatter prop agecatjitter, xlabel(,valuelabel) xlabel(1(1)6) xtitle(Age Category) ylabel(0(10)100) legend(off) ytitle(Percentage) title(Statistic by sex)
This produces a scatter plot with 12 markers with confidence intervals, but they're all the same color. I'm wanting the males whose age categories end in .20 to be one color (say blue), and the females whose age categories end in .80 to be another (say gray) while keeping them on the same graph. Any advice is appreciated. Thank you!
Best,
Andrea
Related Posts with Using rcap scatter but can't figure out how to get 2 different colors of markers
collapse or Roger Newman's xcollapse with string variablesTried help (and the help for xcollapse) but can't get an answer that makes sense to me. I have three…
Why does teffects psmatch number of observations not match number of treated + number of controls with 1 match per treated?My data have 200 treated units and 9,800 untreated units. When I run teffects psmatch using default …
Using Weights for countries in Survey DatasetHello everyone, I am working with 2 waves (5 and 6) of World Value Survey in Stata 15 and I am anal…
IVprobit with 2 endogenous regressorsDear all, I have a regression with binary outcomes and two endogenous continuous regressors. When I…
How to take individuals for which info is available in both waves only?Hi, I am working with BHPS dataset. I have appended Waves 9 & 10 and have declared it as panel. …
Subscribe to:
Post Comments (Atom)
0 Response to Using rcap scatter but can't figure out how to get 2 different colors of markers
Post a Comment